Created
July 7, 2010 12:11
-
-
Save kei-s/466606 to your computer and use it in GitHub Desktop.
user streams with oauth
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'http://rubygems.org' | |
gem 'em-http-request', :require => 'em-http' | |
gem 'oauth' | |
gem 'pit' | |
gem 'yajl-ruby', :require => 'yajl' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# vim:fileencoding=utf-8 | |
require 'uri' | |
require 'rubygems' | |
require 'em-http' | |
require 'oauth' | |
require 'pit' | |
require 'oauth/client/em_http' | |
require 'yajl' | |
config = Pit.get("tweetstream_oauth",:require => { | |
"consumer_key" => "Set Consumer Key", | |
"consumer_secret" => "Set Consumer Secret", | |
"access_token" => "Set Access Token", | |
"access_token_secret" => "Set Access Token Secret" | |
}) | |
oauth_consumer = OAuth::Consumer.new(config['consumer_key'],config['consumer_secret'],:site => 'http://twitter.com') | |
oauth_access_token = OAuth::AccessToken.new(oauth_consumer,config['access_token'],config['access_token_secret']) | |
parser = Yajl::Parser.new | |
parser.on_parse_complete = Proc.new {|data| | |
puts data.inspect | |
} | |
EM.run do | |
request = EventMachine::HttpRequest.new('http://chirpstream.twitter.com/2b/user.json?replies=all') | |
http = request.get(:head => {"Content-Type" => "application/x-www-form-urlencoded"}) do |client| | |
oauth_consumer.sign!(client,oauth_access_token) | |
end | |
http.stream do |chunk| | |
parser << chunk | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment