Skip to content

Instantly share code, notes, and snippets.

@jugyo
Created July 15, 2009 13:59
Show Gist options
  • Save jugyo/147722 to your computer and use it in GitHub Desktop.
Save jugyo/147722 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