简体   繁体   English

Twitter Ruby Gem请求过多

[英]Twitter Ruby Gem Too many requests

I'm currently using TDD with rspec and Ruby on Rails (with twitter gem) to pull tweets and trends for analytics. 我目前正在将TDD与rspec和Ruby on Rails(带有twitter gem)结合使用,以获取有关分析的推文和趋势。 However, I constantly get Twitter::Error::TooManyRequests and have to sit around twiddling thumbs till I can make another request. 但是,我不断收到Twitter::Error::TooManyRequests ,不得不Twitter::Error::TooManyRequests ,直到我可以提出另一个请求为止。 Is this a limitation of Twitter search API or am I doing something wrong? 这是Twitter搜索API的限制还是我做错了什么?

Right now I have a simple index page that invokes Twitter.config once and follows it with Twitter.trends once. 现在,我有一个简单的索引页面,该页面一次调用Twitter.config,然后一次调用Twitter.trends。 Running rspec spec on this to generate one index page results in the previously mentioned error. 在此上运行rspec spec以生成一个索引页会导致前面提到的错误。 Am I missing something here? 我在这里想念什么吗? I can't find anywhere (application, framework, or full traces) where the twitter requests are made in abundance. 在找不到大量Twitter请求的地方(应用程序,框架或完整跟踪),我找不到。

I'm not using the stream API just yet because it only provides raw tweets and not trending information. 我现在还没有使用流API,因为它仅提供原始推文而不提供趋势信息。

您可能想要查看可以记录HTTP交互作用的VCR gem,以便您不会持续访问外部服务。

Twitter has a rate limit of something like 150 requests when not authenticated and 250 requests for authenticated users. Twitter的速率限制为:未经身份验证时有150个请求,对于身份验证用户有250个请求。 Perhaps you could figure a way to gather your data in chunks instead of constant calls. 也许您可以找到一种收集数据而不是进行常量调用的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM