Skip to content

Instantly share code, notes, and snippets.

@ashrithr
Created August 12, 2013 21:44
Show Gist options
  • Save ashrithr/6215583 to your computer and use it in GitHub Desktop.
Save ashrithr/6215583 to your computer and use it in GitHub Desktop.
ruby program to pull data from twitter streaming api
require 'tweetstream'
raise "Requires Argument(s) keyword to match from twitter firehose" if ARGV.length == 0
TweetStream.configure do |config|
# Fill in the details from dev.twitter.com
config.consumer_key = ''
config.consumer_secret = ''
config.oauth_token = ''
config.oauth_token_secret = ''
config.auth_method = :oauth
end
# Twitter Firehose Data that matches keyword(s) from 'ARGV'
begin
TweetStream::Client.new.track(ARGV.join(',')) do |tweet|
# puts tweet.inspect
puts tweet.user['screen_name'] + " => " + tweet.text
end
rescue Interrupt
puts "Caught Interrupt ... Exiting!"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment