Skip to content

Instantly share code, notes, and snippets.

@ravicious
Forked from mattb/gist:148362
Created July 17, 2009 10:11
Show Gist options
  • Save ravicious/148990 to your computer and use it in GitHub Desktop.
Save ravicious/148990 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