Rate limit exceeded with Twitter4j

江枫思渺然 提交于 2019-12-25 04:03:59

问题


I'm using this example for pulling tweets from Twitter. I am getting the error below due to rate limit reached. How do I set the rate?

429:Returned in API v1.1 when a request cannot be served due to the application's rate limit having been exhausted for the resource. See Rate Limiting in API v1.1.(https://dev.twitter.com/docs/rate-limiting/1.1)
message - Rate limit exceeded
code - 88
Relevant discussions can be found on the Internet at:
    http://www.google.co.jp/search?q=506c3b98 or
    http://www.google.co.jp/search?q=102a9b47
TwitterException{exceptionCode=[506c3b98-102a9b47], statusCode=429, message=Rate limit exceeded, code=88, retryAfter=-1, rateLimitStatus=RateLimitStatusJSONImpl{remaining=0, limit=180, resetTimeInSeconds=1424592304, secondsUntilReset=789}, version=4.0.2}
    at twitter4j.HttpClientImpl.handleRequest(HttpClientImpl.java:163)
    at twitter4j.HttpClientBase.request(HttpClientBase.java:53)
    at twitter4j.HttpClientBase.get(HttpClientBase.java:71)
    at twitter4j.TwitterImpl.get(TwitterImpl.java:1538)
    at twitter4j.TwitterImpl.search(TwitterImpl.java:244)
    at tweet4jtest.TweetManager.getTweets(TweetManager.java:23)
    at tweet4jtest.Tweet4jtest.main(Tweet4jtest.java:9)

回答1:


There's many ways to avoid being Rate Limited:

  • You can adapt the search results :

If your application monitors a high volume of search terms, query less often for searches that have no results than for those that do. By using a back-off you can keep up to date on queries that are popular but not waste cycles requesting queries that very rarely change. Alternatively, consider using the The Streaming APIs and filter on your search terms.

  • Store API responses in your application or on your site if you expect a lot of use.
  • Prioritize active users ...

for more details: https://dev.twitter.com/rest/public/rate-limiting

hope this help.



来源:https://stackoverflow.com/questions/28656382/rate-limit-exceeded-with-twitter4j

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!