Reputation: 1543
I am using the twitter gem to search tweets and I want to limit my search results to 10 tweets per function call. I am using the following function
class SayController < ApplicationController
def hello
@tweets = $twitter.search("google", options = {count: 10})
end
end
but I still get thousands of tweets back and it is using up my api rate limits in a couple of page loads
I also tried
@tweets = $twitter.search("google", count: 10)
and
@tweets = $twitter.search("google", count: => 10, :result_type => "recent")
But it never takes the count variable into consideration and does not limit number of tweets fetched. I followed the documentation here http://www.rubydoc.info/gems/twitter/Twitter/REST/Search but I don't understand why it does not work
Upvotes: 1
Views: 376
Reputation: 8730
Try this
@tweets = $twitter.search("google",:result_type => "recent").take(10)
Upvotes: 1