theMap.put("retweet_count", original.getRetweetCount());
private Record extractRecord(String idPrefix, Schema avroSchema, Status status) { User user = status.getUser(); Record doc = new Record(avroSchema); doc.put("id", idPrefix + status.getId()); doc.put("created_at", formatterTo.format(status.getCreatedAt())); doc.put("retweet_count", status.getRetweetCount()); doc.put("retweeted", status.isRetweet()); doc.put("in_reply_to_user_id", status.getInReplyToUserId()); doc.put("in_reply_to_status_id", status.getInReplyToStatusId()); addString(doc, "source", status.getSource()); addString(doc, "text", status.getText()); MediaEntity[] mediaEntities = status.getMediaEntities(); if (mediaEntities.length > 0) { addString(doc, "media_url_https", mediaEntities[0].getMediaURLHttps()); addString(doc, "expanded_url", mediaEntities[0].getExpandedURL()); } doc.put("user_friends_count", user.getFriendsCount()); doc.put("user_statuses_count", user.getStatusesCount()); doc.put("user_followers_count", user.getFollowersCount()); addString(doc, "user_location", user.getLocation()); addString(doc, "user_description", user.getDescription()); addString(doc, "user_screen_name", user.getScreenName()); addString(doc, "user_name", user.getName()); return doc; }
@Override public String getValue() { return status.getRetweetCount() + ""; } },
private boolean retweetedAlready(Status status) throws TwitterException { if(status.isRetweetedByMe() && status.getRetweetCount() > 1 ){ return true; // this twit retweeted by your and others } else if(status.isRetweetedByMe() && status.getRetweetCount() == 1 ) return true; // this twit only retweeted by your }else{ return false; // this twit not retweeted by your but mybe others retweeted }
long userId = 0000000L; try { ResponseList<Status> statusList = twitterObj.timelines().getUserTimeline(userId); for (Status statusItem : statusList) { System.out.println("Tweet Id : " + statusItem.getId() + ", retweet count: " + statusItem.getRetweetCount()); } } catch (TwitterException ex) { // Do error handling things here }
List<Map<String, String>> tweetList = new LinkedList<Map<String, String>>(); for (Status tweet : tweets) { Map<String, String> tweetResult = new LinkedHashMap<String, String>(); tweetResult.put("username", tweet.getUser().getScreenName()); tweetResult.put("status", tweet.getText()); tweetResult.put("date", tweet.getCreatedAt().toString()); tweetResult.put("retweets", String.valueOf(tweet.getRetweetCount())); tweetList.add(tweetResult); } String resultJson = new Gson().toJson(tweetList); response.getWriter().write(resultJson);
for (Status status : result.getTweets()) { System.out.println("RT "+status.getRetweetCount()); System.out.println("FAV "+status.getFavoriteCount()); sb.append(status.getText()+"\n"); }
@Override public List<Object> filter(Status original) { Status status = original.getRetweetedStatus(); if (status == null) { return null; } if(status.getRetweetCount() < retweetCount) { return null; } //Just tweets two days old if(status.getCreatedAt().getTime() + 2*24*60*60*1000 < System.currentTimeMillis()) { return null; } JSONObject msg = new JSONObject(); msg.put("user", original.getUser().getScreenName()); msg.put("photo", original.getUser().getProfileImageURL().toString()); msg.put("tweet", original.getText()); msg.put("id", original.getId()); //msg.put("count", status.getRetweetCount() > 100 ? "> 100" : status.getRetweetCount()); msg.put("count", status.getRetweetCount()); publish(msg.toJSONString()); List<Object> result = new ArrayList<Object>(); result.add(status); return result; }
theMap.put("retweet_count", original.getRetweetCount());
@Override public void onStatus(Status status) { Document tweet = new Document(); tweet.put("_id", status.getId()); tweet.put("createdAt", status.getCreatedAt()); tweet.put("favoriteCount", status.getFavoriteCount()); tweet.put("retweetCount", status.getRetweetCount()); if (status.getGeoLocation() != null) { tweet.put("lat", status.getGeoLocation().getLatitude()); tweet.put("long", status.getGeoLocation().getLongitude()); } tweet.put("screenName", status.getUser().getScreenName()); if (status.getRetweetedStatus() != null) { tweet.put("retweetedStatus", status.getRetweetedStatus().getText()); } tweet.put("text", status.getText()); Document query = new Document(); query.put("_id", status.getId()); collection.replaceOne(query, tweet, new UpdateOptions().upsert(true)); }
private Record extractRecord(String idPrefix, Schema avroSchema, Status status) { User user = status.getUser(); Record doc = new Record(avroSchema); doc.put("id", idPrefix + status.getId()); doc.put("created_at", formatterTo.format(status.getCreatedAt())); doc.put("retweet_count", status.getRetweetCount()); doc.put("retweeted", status.isRetweet()); doc.put("in_reply_to_user_id", status.getInReplyToUserId()); doc.put("in_reply_to_status_id", status.getInReplyToStatusId()); addString(doc, "source", status.getSource()); addString(doc, "text", status.getText()); MediaEntity[] mediaEntities = status.getMediaEntities(); if (mediaEntities.length > 0) { addString(doc, "media_url_https", mediaEntities[0].getMediaURLHttps()); addString(doc, "expanded_url", mediaEntities[0].getExpandedURL()); } doc.put("user_friends_count", user.getFriendsCount()); doc.put("user_statuses_count", user.getStatusesCount()); doc.put("user_followers_count", user.getFollowersCount()); addString(doc, "user_location", user.getLocation()); addString(doc, "user_description", user.getDescription()); addString(doc, "user_screen_name", user.getScreenName()); addString(doc, "user_name", user.getName()); return doc; }
.put("FavoriteCount", status.getFavoriteCount()) .put("Retweet", status.isRetweet()) .put("RetweetCount", status.getRetweetCount()) .put("RetweetedByMe", status.isRetweetedByMe()) .put("CurrentUserRetweetId", status.getCurrentUserRetweetId())