Created
July 17, 2010 00:04
-
-
Save stevegraham/479087 to your computer and use it in GitHub Desktop.
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
%w(rubygems eventmachine em-http-request yajl).each { |lib| require lib } | |
module Twitter | |
def on_tweet() lambda { |obj| puts obj['text'] }; end | |
extend self | |
end | |
EM::run do | |
req = EM::HttpRequest.new('http://stream.twitter.com/1/statuses/sample.json').get :head => { 'authorization' => ['eventmachine', 'eventm4chine'] } | |
parser = Yajl::Parser.new.tap { |p| p.on_parse_complete = Twitter.on_tweet } | |
req.stream { |chunk| parser << chunk } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment