status.getText(), null, Long.toString(status.getId()), null, false));
Status status; String url= "https://twitter.com/" + status.getUser().getScreenName() + "/status/" + status.getId(); System.out.println(url);
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 boolean equals(Object obj) { if (null == obj) { return false; } if (this == obj) { return true; } return obj instanceof Status && ((Status) obj).getId() == this.id; }
@Override public String getValue() { return status.getId() + ""; } },
@Override public int compareTo(Status that) { long delta = this.id - that.getId(); if (delta < Integer.MIN_VALUE) { return Integer.MIN_VALUE; } else if (delta > Integer.MAX_VALUE) { return Integer.MAX_VALUE; } return (int) delta; }
List<Status> retweets = twitter.getRetweetedByMe(); for (Status retweet : retweets) { if(retweet.getRetweetedStatus().getId() == ID_OF_TWEET_YOU_DONT_WANT_TO_RETWEET_ANYMORE) twitter.destroyStatus(retweet.getId()); }
public class StatusTypeHandler implements TypeHandler<Status> { public Status getResult(ResultSet rs, String param) throws SQLException { return Status.getEnum(rs.getInt(param)); } public Status getResult(CallableStatement cs, int col) throws SQLException { return Status.getEnum(cs.getInt(col)); } public void setParameter(PreparedStatement ps, int paramInt, Status paramType, JdbcType jdbctype) throws SQLException { ps.setInt(paramInt, paramType.getId()); } }
StatusUpdate statusUpdate = new StatusUpdate(mfinalmsg); if (imgdata != null) { ByteArrayInputStream bis = new ByteArrayInputStream(imgdata); statusUpdate.setMedia("pic", bis); } Status status = twitter.updateStatus(statusUpdate); long statusId = (int)status.getId();
final QueryResult result = twitter.search(query); // 100 Tweets final Status lastStatus = getLast(result.getTweets()); query.sinceId(lastStatus.getId()); final QueryResult nextResult = twitter.search(query); // Another 100 Tweets // and so on...
boolean finished = false; while (!finished) { final QueryResult result = twitter.search(query); final List<Status> statuses = result.getTweets(); long lowestStatusId = Long.MAX_VALUE; for (Status status : statuses) { // do your processing here and work out if you are 'finished' etc... // Capture the lowest (earliest) Status id lowestStatusId = Math.min(status.getId(), lowestStatusId); } // Subtracting one here because 'max_id' is inclusive query.setMaxId(lowestStatusId - 1); }
AccessToken accessToken = new AccessToken(token,secret); Twitter twitter = new TwitterFactory().getOAuthAuthorizedInstance(consumerKey,consumerSecret,accessToken); Status status = twitter.updateStatus("My First Status Update"); statusId = (int)status.getId();
@Override public List<Exchange> pollConsume() throws TwitterException { List<Status> statusList = doPoll(); for (int i = 0; i < statusList.size(); i++) { setLastIdIfGreater(statusList.get(i).getId()); } return TwitterEventType.STATUS.createExchangeList(endpoint, statusList); }
private Status updateStatus(String status) throws Exception { Status response = endpoint.getProperties().getTwitter().updateStatus(status); log.debug("Updated status: {}", status); log.debug("Status id: {}", response.getId()); return response; } }
private Status updateStatus(StatusUpdate status) throws Exception { Status response = endpoint.getProperties().getTwitter().updateStatus(status); log.debug("Updated status: {}", status); log.debug("Status id: {}", response.getId()); return response; }
private void extractRetweetedStatuses(Status tweet, Set<Content> contents, Status retweeted) { if (retweeted != null) { Content retweetedStatus = newBase(tweet); retweetedStatus.setContentName(String.valueOf(retweeted.getId())); retweetedStatus.setContentType("status_retweeted"); contents.add(retweetedStatus); } }
/** * @return The previously oldest loaded tweets for use in {@link #loadMoreTweets()}. */ private Optional<Status> getOldestTweetLoaded() { if (tweetsProperty.isEmpty()) { getLogger().debug("No older tweets to load."); return Optional.empty(); } final Status oldest = tweetsProperty.getValue().get(tweetsProperty.size() - 1); getLogger().debug("Loading tweets before {}", oldest.getId()); return Optional.of(oldest); }
/** * Returns whether or not the given tweet has not yet been liked and that thus the interaction with it should be to * like it. * * @param tweet the tweet to check * * @return true if the given tweet is not liked yet but the current user */ boolean notYetLiked(final Status tweet) { return !sessionManager.doWithCurrentTwitter(twitter -> twitter.showStatus(tweet.getId()).isFavorited()) .get(); }
private void replyTo(final Status status, final String reply, final boolean prefix) throws TwitterException { final String message; if (prefix) { message = "@" + status.getUser().getScreenName() + " " + reply; } else { message = reply; } final StatusUpdate statusUpdate = new StatusUpdate(message); statusUpdate.setInReplyToStatusId(status.getId()); twitter.updateStatus(statusUpdate); }