-
-
Save gom/147774 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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