简体   繁体   中英

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. However, I constantly get Twitter::Error::TooManyRequests and have to sit around twiddling thumbs till I can make another request. Is this a limitation of Twitter search API or am I doing something wrong?

Right now I have a simple index page that invokes Twitter.config once and follows it with Twitter.trends once. Running rspec spec on this to generate one index page results in the previously mentioned error. Am I missing something here? I can't find anywhere (application, framework, or full traces) where the twitter requests are made in abundance.

I'm not using the stream API just yet because it only provides raw tweets and not trending information.

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

Twitter has a rate limit of something like 150 requests when not authenticated and 250 requests for authenticated users. Perhaps you could figure a way to gather your data in chunks instead of constant calls.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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