0

I do some analysis on twitter users features like number of following , number of retweet, number of friend , etc I have all my information from Twitter Rest API But there is an Rate Limit Exceeded error occurred when I tried to retrieve all data can I have all these data from Twitter Streaming API , if I can , how I can you it? If not what Is the Solution?

Thanks for Help

RProgrammer
  • 47
  • 1
  • 8

1 Answers1

0

On each response you can call getRateLimitStatus() to get a RateLimitStatus and if remaining calls is 0, sleep the thread till time limit is over.

do {
    TwitterResponse response = twitter.getFollowersIDs(userId, cursor);
    RateLimitStatus status = response.getRateLimitStatus();
    if(status.getRemaining() == 0) {
        try {
            Thread.sleep(status.getSecondsUntilReset() * 1000);
        }
        catch(InterruptedException e) {
            // ...
        }
    }
} while(cursor > 0);

Twitter API update limits error 403

Community
  • 1
  • 1
Ramanan
  • 1,000
  • 1
  • 7
  • 20