Skip to content

Instantly share code, notes, and snippets.

Created January 6, 2014 16:15
Show Gist options
  • Save anonymous/7c9adb1460b350e82d4f to your computer and use it in GitHub Desktop.
Save anonymous/7c9adb1460b350e82d4f to your computer and use it in GitHub Desktop.
require 'twitter'
SEARCH_STR = "#helloworld"
COUNT = 10
client = Twitter::REST::Client.new do |config|
# you must set up an application using Twitter's developer site, and set these values:
# (See the Configuration example)
config.consumer_key = ""
config.consumer_secret = ""
config.access_token = ""
config.access_token_secret = ""
end
opts = { :count => COUNT, :result_type => 'recent' }
client.search(SEARCH_STR, opts).each do |tweet|
text = tweet.attrs[:text]
name = tweet.attrs[:user][:name]
screen_name = tweet.attrs[:user][:screen_name]
created_at = tweet.attrs[:created_at]
puts "#{name} (@#{screen_name}): #{text} [Created #{created_at}]"
end
but after the script show 10 msg, it show also:
/Users/riccardo/.rvm/gems/ruby-2.0.0-p247/gems/twitter-5.5.0/lib/twitter/rest/client.rb:143:in `rescue in request': execution expired (Twitter::Error)
from /Users/riccardo/.rvm/gems/ruby-2.0.0-p247/gems/twitter-5.5.0/lib/twitter/rest/client.rb:131:in `request'
from /Users/riccardo/.rvm/gems/ruby-2.0.0-p247/gems/twitter-5.5.0/lib/twitter/rest/client.rb:97:in `get'
from /Users/riccardo/.rvm/gems/ruby-2.0.0-p247/gems/twitter-5.5.0/lib/twitter/search_results.rb:68:in `fetch_next_page'
from /Users/riccardo/.rvm/gems/ruby-2.0.0-p247/gems/twitter-5.5.0/lib/twitter/enumerable.rb:13:in `each'
from hello.rb:17:in `<main>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment