【发布时间】:2015-08-11 13:32:10
【问题描述】:
我正在使用下面的代码使用 Twitter API,并且我在循环内达到了 API 速率限制。
我的问题是:我是如何达到速率限制的?我相信当我分配 myFollowers 时我只进行一次 API 调用,并且在循环中我只是查看 myFolwers 中每个对象的位置值,这应该只是服务器端处理。
require 'twitter'
client = Twitter::REST::Client.new do |config|
config.consumer_key = "xx"
config.consumer_secret = "xx"
config.access_token = "xx"
config.access_token_secret = "xx"
end
myFollowers = client.followers("mytwittername")
myFollowers.each do |follower|
if follower.location.include? 'New'
print Name: follower.name
puts Location: follower.location
end
end
【问题讨论】:
-
您是否使用网络捕获工具检查它是否有一个或多个调用?像 ngrep 或 wireshark 之类的东西。
-
这是最好的选择。虽然客户端看起来应该是对 API 的简单且单一的调用,但您永远不知道引擎盖下到底发生了什么。