Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter Gem Search method

My code is here

require 'twitter'



search = Twitter::Search.new.containing("obama")

it returns us

 #<Twitter::Search:0xb6881f9c @proxy=nil, @gateway=nil, @format=:json, @search_endpoint="https://search.twitter.com/", @consumer_key=nil, @adapter=:net_http, @endpoint="https://api.twitter.com/1/", @oauth_token_secret=nil, @query={:q=>["obama"], :tude=>[]}, @oauth_token=nil, @consumer_secret=nil, @user_agent="Twitter Ruby Gem 1.6.2", @cache=nil>

I want to search only public tweets that contain obama

How can i do this

like image 600
Ravendra Kumar Avatar asked Mar 16 '26 23:03

Ravendra Kumar


1 Answers

Did you try

Twitter.search('Obama') 

or

Twitter.search('Obama', options = {}) 

Also I noticed you are missing Authentication atributes. Take a look into Twitter API Doc to make sure you have all the 'required' params.

PS: Do you want to search all the tweets that contains the string 'Obama' or all tweets with #Obama. The search result-set and the accuracy is different for both the searches.

like image 78
Som Poddar Avatar answered Mar 18 '26 13:03

Som Poddar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!