Skip to content

Instantly share code, notes, and snippets.

@komiya-atsushi
Created November 8, 2012 17:06
Show Gist options
  • Save komiya-atsushi/4040109 to your computer and use it in GitHub Desktop.
Save komiya-atsushi/4040109 to your computer and use it in GitHub Desktop.
RateLimitStatus#getSecondsUntilReset() returns a negative value. ( #twitter4j 3.0.0 )
import twitter4j.RateLimitStatus;
import twitter4j.Twitter;
import twitter4j.TwitterException;
import twitter4j.TwitterFactory;
public class GetSecondsUntilResetDemo {
public static void main(String[] args) throws TwitterException {
Twitter twitter = TwitterFactory.getSingleton();
System.out
.println("RateLimitStatus#getSecondsUntilReset() returns a negative value.\n");
RateLimitStatus rls = twitter.getHomeTimeline().getRateLimitStatus();
System.out.printf("ResponseList#getRateLimitStatus() : %d (%s)\n",
rls.getSecondsUntilReset(), rls.toString());
rls = twitter.getRateLimitStatus("followers").get("/followers/ids");
System.out.printf("Twitter#getRateLimitStatus() : %d (%s)\n",
rls.getSecondsUntilReset(), rls.toString());
for (int i = 0; i < 20; i++) {
try {
twitter.getTermsOfService();
} catch (TwitterException e) {
rls = e.getRateLimitStatus();
System.out.printf(
"TwitterException#getRateLimitStatus() : %d (%s)\n",
rls.getSecondsUntilReset(), rls.toString());
break;
}
}
}
}
RateLimitStatus#getSecondsUntilReset() returns negative value.
ResponseList#getRateLimitStatus() : -1351041639 (RateLimitStatusJSONImpl{remaining=14, limit=15, resetTimeInSeconds=1352394, secondsUntilReset=-1351041639})
Twitter#getRateLimitStatus() : -1352913792 (RateLimitStatusJSONImpl{remaining=15, limit=15, resetTimeInSeconds=1352394940, secondsUntilReset=-1352913792})
TwitterException#getRateLimitStatus() : -1351041644 (RateLimitStatusJSONImpl{remaining=0, limit=15, resetTimeInSeconds=1352394, secondsUntilReset=-1351041644})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment