Twitter api with curl works but ruby twitter-stream does not?

can anyone tell me why connecting to twitter using curl works and with
twitter-stream it doesnt (i am using the example code from the gem
website on github:

using curl:
echo ‘track=software,ruby,rails,grails,torquebox,spring,tomcat,jboss’ >
track.in
curl -d @track.in https://stream.twitter.com/1/statuses/filter.json
-uUSERNAME:PASSWORD

everything works:

however when using twitter-stream; i get rejected (something with ssl;
however, i dont know why the curl client works):

require ‘rubygems’
require ‘twitter/json_stream’

username=‘user’
password=‘password’

username=ARGV[0] if ARGV[0]
password=ARGV[1] if ARGV[1]
auth="#{username}:#{password}"

puts “running twitter with auth => #{auth}”

EventMachine::run {
stream = Twitter::JSONStream.connect(
:path => ‘/1/statuses/filter.json’,
:auth => auth,
:method => ‘POST’,
#:ssl => true,
:content =>
‘track=software,ruby,rails,grails,torquebox,spring,tomcat,jboss’
)

stream.each_item do |item|
$stdout.print “item: #{item}\n”
$stdout.flush
end

stream.on_error do |message|
$stdout.print “error: #{message}\n”
$stdout.flush
end

stream.on_reconnect do |timeout, retries|
$stdout.print “reconnecting in: #{timeout} seconds\n”
$stdout.flush
end

stream.on_max_reconnects do |timeout, retries|
$stdout.print “Failed after #{retries} failed reconnects\n”
$stdout.flush
end

trap(‘TERM’) {
stream.stop
EventMachine.stop if EventMachine.reactor_running?
}
}
puts “The event loop has ended”

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs