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:
https://github.com/voloko/twitter-stream/blob/master/examples/reader.rb

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"


--
Thank You,
Matthew Purdy

------------------------------------------------------------------------------------------------------------------
Matthew Purdy
mpurdy1973userGroups@gmail.com
443.848.1595
--------------------------------------
"Lead, follow, or get out of the way." -- Thomas Paine
"Make everything as simple as possible, but not simpler." -- Albert Einstein
"The definition of insanity is doing the same thing over and over and
expecting a different result." -- Benjamin Franklin
"We can't solve problems by using the same kind of thinking we used when we
created them." -- Albert Einstein
------------------------------------------------------------------------------------------------------------------

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedMar 7, '12 at 12:56a
activeMar 7, '12 at 12:56a
posts1
users1
websiterubyonrails.org
irc#RubyOnRails

1 user in discussion

Matthew Purdy: 1 post

People

Translate

site design / logo © 2021 Grokbase