2015-10-21 51 views
1

我使用twitter gem搜索推文,並且我想將每次函數調用的搜索結果限制爲10條推文。我使用下面的函數Rails twitter gem搜索功能不限制推文的數量

class SayController < ApplicationController 
    def hello 
    @tweets = $twitter.search("google", options = {count: 10}) 
    end 
end 

,但我仍然得到成千上萬的鳴叫回來了,它是在幾個頁面加載的

我也試過

 @tweets = $twitter.search("google", count: 10) 

使用了我的API速率限制和

@tweets = $twitter.search("google", count: => 10, :result_type => "recent") 

但它從來沒有考慮計數變量的考慮,並沒有限制麻木呃取得的推文。我在這裏http://www.rubydoc.info/gems/twitter/Twitter/REST/Search跟着文檔,但我不明白爲什麼它不工作

+0

您正在使用什麼版本的嘗試?如果你嘗試使用參數'rpp'而不是'count'呢? –

回答

1

@tweets = $twitter.search("google",:result_type => "recent").take(10) 
+0

謝謝,這工作,爲什麼要限制API調用?而不是參數? – Sakib