List of usage examples for twitter4j Status getCreatedAt
Date getCreatedAt();
From source file:com.freshdigitable.udonroad.StatusViewBase.java
License:Apache License
@CallSuper public void bindStatus(final Status status) { final Status bindingStatus = getBindingStatus(status); bindCreatedAt(bindingStatus.getCreatedAt()); if (status.isRetweet()) { setTextColor(ContextCompat.getColor(getContext(), R.color.twitter_action_retweeted)); }/*from ww w .ja v a 2s.c om*/ final User user = bindingStatus.getUser(); bindTweetUserName(user); bindText(status); bindSource(bindingStatus); bindRT(bindingStatus); bindFavorite(bindingStatus); bindMediaEntities(status); }
From source file:com.freshdigitable.udonroad.StatusViewBase.java
License:Apache License
@CallSuper public void update(Status status) { final Status bindingStatus = getBindingStatus(status); bindCreatedAt(bindingStatus.getCreatedAt()); bindRT(bindingStatus);// w ww.j ava 2s . c o m bindFavorite(bindingStatus); final User user = bindingStatus.getUser(); bindTweetUserName(user); }
From source file:com.freshdigitable.udonroad.util.TwitterResponseMock.java
License:Apache License
public static Status createStatus(long id, User user) { final Status status = mock(Status.class); when(status.getId()).thenReturn(id); when(status.getCreatedAt()).thenReturn(new Date()); when(status.getText()).thenReturn(createText(id)); when(status.isRetweet()).thenReturn(false); when(status.getSource()).thenReturn("<a href=\"https://twitter.com/akihito104\">Udonroad</a>"); when(status.getURLEntities()).thenReturn(new URLEntity[0]); when(status.getExtendedMediaEntities()).thenReturn(new ExtendedMediaEntity[0]); when(status.getUserMentionEntities()).thenReturn(new UserMentionEntity[0]); when(status.getUser()).thenReturn(user); return status; }
From source file:com.fuzuapp.model.resultados.TwitterAdapter.java
@Override public List<Resultado> getResultados(GeoPoint ponto, double raio) { List<Resultado> resultados = new ArrayList(); try {/* w w w. j a v a 2 s. c o m*/ Query query = new Query(""); GeoLocation geo = new GeoLocation(ponto.getLatitude(), ponto.getLongitude()); query.setGeoCode(geo, raio, Query.KILOMETERS); query.resultType(Query.RECENT); query.setCount(20); QueryResult result = twitter.search(query); for (Status status : result.getTweets()) { Resultado r = new Resultado(); r.setDescricao(status.getText()); r.setUrl("http://twitter.com/statuses/" + String.valueOf(status.getId())); r.setNomeUsuario(status.getUser().getName()); r.setHorario(new SimpleDateFormat("dd/MM HH:mm").format(status.getCreatedAt())); r.setFotoUrl(status.getUser().getProfileImageURL()); //r.setLocal(new GeoPoint(status.getGeoLocation().getLatitude(), status.getGeoLocation().getLongitude())); r.setTipo(Resultado.TEXTO); resultados.add(r); } } catch (TwitterException ex) { Logger.getLogger(TwitterAdapter.class.getName()).log(Level.SEVERE, null, ex); } return resultados; }
From source file:com.github.jcustenborder.kafka.connect.twitter.StatusConverter.java
License:Apache License
public static void convert(Status status, Struct struct) { struct.put("CreatedAt", status.getCreatedAt()).put("Id", status.getId()).put("Text", status.getText()) .put("Source", status.getSource()).put("Truncated", status.isTruncated()) .put("InReplyToStatusId", status.getInReplyToStatusId()) .put("InReplyToUserId", status.getInReplyToUserId()) .put("InReplyToScreenName", status.getInReplyToScreenName()).put("Favorited", status.isFavorited()) .put("Retweeted", status.isRetweeted()).put("FavoriteCount", status.getFavoriteCount()) .put("Retweet", status.isRetweet()).put("RetweetCount", status.getRetweetCount()) .put("RetweetedByMe", status.isRetweetedByMe()) .put("CurrentUserRetweetId", status.getCurrentUserRetweetId()) .put("PossiblySensitive", status.isPossiblySensitive()).put("Lang", status.getLang()); Struct userStruct;/*from w w w .j a v a 2 s . co m*/ if (null != status.getUser()) { userStruct = new Struct(USER_SCHEMA); convert(status.getUser(), userStruct); } else { userStruct = null; } struct.put("User", userStruct); Struct placeStruct; if (null != status.getPlace()) { placeStruct = new Struct(PLACE_SCHEMA); convert(status.getPlace(), placeStruct); } else { placeStruct = null; } struct.put("Place", placeStruct); Struct geoLocationStruct; if (null != status.getGeoLocation()) { geoLocationStruct = new Struct(GEO_LOCATION_SCHEMA); convert(status.getGeoLocation(), geoLocationStruct); } else { geoLocationStruct = null; } struct.put("GeoLocation", geoLocationStruct); List<Long> contributers = new ArrayList<>(); if (null != status.getContributors()) { for (Long l : status.getContributors()) { contributers.add(l); } } struct.put("Contributors", contributers); List<String> withheldInCountries = new ArrayList<>(); if (null != status.getWithheldInCountries()) { for (String s : status.getWithheldInCountries()) { withheldInCountries.add(s); } } struct.put("WithheldInCountries", withheldInCountries); struct.put("HashtagEntities", convert(status.getHashtagEntities())); struct.put("UserMentionEntities", convert(status.getUserMentionEntities())); struct.put("MediaEntities", convert(status.getMediaEntities())); struct.put("SymbolEntities", convert(status.getSymbolEntities())); struct.put("URLEntities", convert(status.getURLEntities())); }
From source file:com.hortonworks.amuise.cdrstorm.kafka.producers.CDRTestDataProducer.java
private void start() { /**//from w w w . j a va 2s.com * Kafka Twitter Producer properties * */ Properties twitterconprops = new Properties(); twitterconprops.put("metadata.broker.list", globalconfigs.getProperty("twitter4j.brokerlist")); twitterconprops.put("serializer.class", globalconfigs.getProperty("twitter4j.serializer")); twitterconprops.put("request.required.acks", globalconfigs.getProperty("twitter4j.requiredacks")); ProducerConfig twitterproducerconfig = new ProducerConfig(twitterconprops); final Producer<String, String> twitterproducer = new Producer<String, String>(twitterproducerconfig); /** * Kafka CDR Producer properties * */ Properties cdrconprops = new Properties(); cdrconprops.put("metadata.broker.list", globalconfigs.getProperty("cdr.brokerlist")); cdrconprops.put("serializer.class", globalconfigs.getProperty("cdr.serializer")); cdrconprops.put("request.required.acks", globalconfigs.getProperty("cdr.requiredacks")); ProducerConfig cdrproducerconfig = new ProducerConfig(cdrconprops); final Producer<String, String> cdrproducer = new Producer<String, String>(cdrproducerconfig); /** * Twitter4j properties * */ ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setOAuthConsumerKey(globalconfigs.getProperty("twitter4j.consumerkey")); cb.setOAuthConsumerSecret(globalconfigs.getProperty("twitter4j.consumersecretkey")); cb.setOAuthAccessToken(globalconfigs.getProperty("twitter4j.accesstokenkey")); cb.setOAuthAccessTokenSecret(globalconfigs.getProperty("twitter4j.accesstokensecretkey")); cb.setJSONStoreEnabled(true); cb.setIncludeEntitiesEnabled(true); twitterStream = new TwitterStreamFactory(cb.build()).getInstance(); /** * Twitter listener * */ StatusListener listener = new StatusListener() { // The onStatus method is executed every time a new tweet comes // in. public void onStatus(Status status) { StringBuilder sb = new StringBuilder(); sb.append(status.getUser().getScreenName()); sb.append("|"); sb.append(status.getCreatedAt()); sb.append("|"); sb.append(status.getRetweetCount()); sb.append("|"); sb.append(status.getSource()); sb.append("|"); sb.append(status.getText()); //call CDR create message String cdrmessage = createCDRMessage(status.getText()); //Debug output System.out.println("_________________________________________________________"); System.out.println(sb.toString()); System.out.println("cdr message: " + cdrmessage); System.out.println("_________________________________________________________"); //call producer for tweet KeyedMessage<String, String> twitterdata = new KeyedMessage<String, String>( globalconfigs.getProperty("twitter4j.kafkatopic"), sb.toString()); twitterproducer.send(twitterdata); //call producer for cdr KeyedMessage<String, String> cdrmessagedata = new KeyedMessage<String, String>( globalconfigs.getProperty("cdr.kafkatopic"), cdrmessage); cdrproducer.send(cdrmessagedata); } public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) { } public void onTrackLimitationNotice(int numberOfLimitedStatuses) { } public void onScrubGeo(long userId, long upToStatusId) { } public void onException(Exception ex) { System.out.println("General Exception: shutting down Twitter sample stream..."); System.out.println(ex.getMessage()); ex.printStackTrace(); twitterStream.shutdown(); } public void onStallWarning(StallWarning warning) { } }; twitterStream.addListener(listener); // Filter stream with targeted words String filterstring = globalconfigs.getProperty("twitter4j.filterwords"); FilterQuery filterq = new FilterQuery(); filterq.track(filterstring.split(",")); twitterStream.filter(filterq); //twitterStream.sample(); }
From source file:com.infine.android.devoxx.service.TwitterService.java
License:Apache License
private ContentProviderOperation buildCPOperation(Status tweet) { final ContentProviderOperation.Builder builder = ContentProviderOperation .newInsert(ScheduleContract.Tweets.CONTENT_URI); // affecte les valeurs des colonnes builder.withValue(ScheduleContract.Tweets.TWEET_ID, tweet.getId()); builder.withValue(ScheduleContract.Tweets.CREATION_DATE, tweet.getCreatedAt().getTime()); builder.withValue(ScheduleContract.Tweets.IMAGE_URL, tweet.getUser().getProfileImageURL()); builder.withValue(ScheduleContract.Tweets.TEXT, tweet.getText()); builder.withValue(ScheduleContract.Tweets.USER, tweet.getUser().getName()); builder.withValue(ScheduleContract.Tweets.USER_NAME, tweet.getUser().getScreenName()); return builder.build(); }
From source file:com.javielinux.infos.InfoTweet.java
License:Apache License
public InfoTweet(Status status) { urls = new ArrayList<URLContent>(); mTypeFrom = FROM_STATUS;//from w w w . j a v a 2s . c o m id = status.getId(); urlAvatar = status.getUser().getProfileImageURL().toString(); userId = status.getUser().getId(); text = status.getText(); username = status.getUser().getScreenName(); fullname = status.getUser().getName(); source = status.getSource(); toUsername = status.getInReplyToScreenName(); toUserId = status.getInReplyToUserId(); createAt = status.getCreatedAt(); toReplyId = status.getInReplyToStatusId(); favorited = status.isFavorited(); if (status.getGeoLocation() != null) { latitude = status.getGeoLocation().getLatitude(); longitude = status.getGeoLocation().getLongitude(); } if (status.getRetweetedStatus() != null) { retweet = true; urlAvatarRetweet = status.getRetweetedStatus().getUser().getProfileImageURL().toString(); textRetweet = status.getRetweetedStatus().getText(); usernameRetweet = status.getRetweetedStatus().getUser().getScreenName(); fullnameRetweet = status.getRetweetedStatus().getUser().getName(); sourceRetweet = status.getRetweetedStatus().getSource(); } urlTweet = "http://twitter.com/#!/" + username.toLowerCase() + PREFIX_URL_TWITTER + id; calculateLinks(); }
From source file:com.joanzapata.android.twitter.TwitterFragment.java
License:Apache License
@AfterViews void afterViews() { setRetainInstance(true);/* w ww .j a v a 2 s.c o m*/ getSherlockActivity().setTitle("@" + followingAccount); listView.setOnEndOfListListener(this); if (adapter == null) adapter = new QuickAdapter<Status>(getSherlockActivity(), R.layout.tweet) { @Override protected void convert(BaseAdapterHelper helper, Status status) { boolean isRetweet = status.isRetweet(); if (isRetweet) status = status.getRetweetedStatus(); helper.setText(tweetText, status.getText()).setVisible(tweetRT, isRetweet) .setText(tweetName, status.getUser().getName()) .setText(tweetDate, dateFormat.format(status.getCreatedAt())) .setImageUrl(tweetAvatar, status.getUser().getProfileImageURL()).linkify(tweetText); } }; listView.setAdapter(adapter); }
From source file:com.joshlong.esb.springintegration.modules.social.twitter.TwitterMessageSource.java
License:Apache License
private Tweet buildTweetFromStatus(Status firstPost) { Tweet tweet = new Tweet(firstPost.getId(), firstPost.getUser().getName(), firstPost.getCreatedAt(), firstPost.getText());/* w w w . j av a2 s . c o m*/ return tweet; }