在下面的代码中,我指定我想向 twitter api 发出 1 个请求,但是当我puts
输出到终端时,我继续收到许多响应,直到我终止程序。如何将其限制为仅指定数量的请求?我是红宝石的新手,所以我可能在这里明显遗漏了一些东西。
require 'twitter'
...
client = Twitter::REST::Client.new do |config|
config.consumer_key = credentials[:consumer_key]
config.consumer_secret = credentials[:consumer_secret]
config.access_token = credentials[:access_token]
config.access_token_secret = credentials[:access_token_secret]
end
search_results = client.search "China", {:count => 1, :lang => 'en', :result_type => 'recent'}
search_results.each do |value|
puts value.user.screen_name
end