我正在使用twitter gem搜索推文,我希望将每个函数调用的搜索结果限制为10条推文。我正在使用以下功能
class SayController < ApplicationController
def hello
@tweets = $twitter.search("google", options = {count: 10})
end
end
但是我仍然收到了数千条推文,并且在几页加载中消耗了我的api速率限制
我也试过
@tweets = $twitter.search("google", count: 10)
和
@tweets = $twitter.search("google", count: => 10, :result_type => "recent")
但它永远不会考虑计数变量,也不会限制提取的推文数量。我按照http://www.rubydoc.info/gems/twitter/Twitter/REST/Search中的文档进行了操作,但我不明白为什么它不起作用
答案 0 :(得分:1)
试试这个
@tweets = $twitter.search("google",:result_type => "recent").take(10)