Skip to content

Instantly share code, notes, and snippets.

@mattb
Created July 16, 2009 11:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mattb/148362 to your computer and use it in GitHub Desktop.
Save mattb/148362 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'eventmachine'
require 'yajl'
require 'em-http'
require 'uri'
EventMachine.run {
body = ''
on_body = lambda { |chunk|
chunk.split(/\n/).each { |json|
data = Yajl::Parser.new.parse(json)
puts "#{data['user']['name']}: #{data['text']}"
}
}
http = EventMachine::HttpRequest.new(URI.parse('http://stream.twitter.com/track.json')).post(
:query => {'track' => 'dopplr'},
:head => {'authorization' => ['user', 'pass']},
:on_response => on_body)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment