Skip to content

Instantly share code, notes, and snippets.

@gom
Forked from jugyo/twitter_stream_api_test.rb
Created July 15, 2009 14:45
Show Gist options
  • Save gom/147774 to your computer and use it in GitHub Desktop.
Save gom/147774 to your computer and use it in GitHub Desktop.
# Usage:
# ruby twitter_stream_api_test.rb USERNAME PASSWORD
require 'rubygems'
require "socket"
require 'base64'
require 'json'
username, password = *ARGV[0..1]
s = TCPSocket.open("stream.twitter.com", 80)
auth = Base64.b64encode("#{username}:#{password}")
s.write <<EOS
GET /spritzer.json HTTP/1.1
Host: stream.twitter.com
Authorization: Basic #{auth}
EOS
begin
while str = s.gets
json = JSON.parse(str) rescue nil
p json if json
end
ensure
s.close
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment