Twitter4j 超出了速率限制 [英] Rate limit exceeded with Twitter4j

查看:72
本文介绍了Twitter4j 超出了速率限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 this 示例从 Twitter 中提取推文.由于达到速率限制,我收到以下错误.如何设置费率?

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)

推荐答案

有很多方法可以避免被限速:

There's many ways to avoid being Rate Limited:

  • 您可以调整搜索结果:

如果您的应用程序监控大量搜索词,那么对没有结果的搜索进行查询的频率要低于有结果的搜索.通过使用回退,您可以及时了解流行的查询,但不会浪费请求很少更改的查询的周期.或者,考虑使用 The Streaming API 并过滤您的搜索词.

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.

  • 如果您希望大量使用,请将 API 响应存储在您的应用程序或网站上.
  • 优先考虑活跃用户...
  • 了解更多详情:https://dev.twitter.com/rest/public/限速

    希望对您有所帮助.

    这篇关于Twitter4j 超出了速率限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆