mattb (owner)

Forks

Revisions

gist: 148362 Download_button fork
public
Public Clone URL: git://gist.github.com/148362.git
Embed All Files: show embed
Ruby #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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)
}