-2

How can I collect real-time tweets using Ruby and store them in MongoDB? Please give me a hint! I've tried to use this code 1 and always get this one and dont know how to deal with it...

C:/Ruby187/lib/ruby/1.8/net/protocol.rb:135:in `sysread': 既存の接続はリモート
ホストに強制的に切断されました。 (Errno::ECONNRESET)
        from C:/Ruby187/lib/ruby/1.8/net/protocol.rb:135:in `rbuf_fill'
        from C:/Ruby187/lib/ruby/1.8/timeout.rb:67:in `timeout'
        from C:/Ruby187/lib/ruby/1.8/timeout.rb:101:in `timeout'
        from C:/Ruby187/lib/ruby/1.8/net/protocol.rb:134:in `rbuf_fill'
        from C:/Ruby187/lib/ruby/1.8/net/protocol.rb:116:in `readuntil'
        from C:/Ruby187/lib/ruby/1.8/net/protocol.rb:126:in `readline'
        from C:/Ruby187/lib/ruby/1.8/net/http.rb:2028:in `read_status_line'
        from C:/Ruby187/lib/ruby/1.8/net/http.rb:2017:in `read_new'
        from C:/Ruby187/lib/ruby/1.8/net/http.rb:1051:in `request'
        from stream.rb:19
        from C:/Ruby187/lib/ruby/1.8/net/http.rb:543:in `start'
        from C:/Ruby187/lib/ruby/1.8/net/http.rb:440:in `start'
        from stream.rb:15
NSNoob
  • 5,548
  • 6
  • 41
  • 54
Dulos Adam
  • 13
  • 1
  • 3
  • I've tried to use this code https://gist.github.com/656397 but it seems useless coz can't run it – Dulos Adam Apr 21 '12 at 08:33
  • Can't run it. Why? Please read [this](http://msmvps.com/blogs/jon_skeet/archive/2010/08/29/writing-the-perfect-question.aspx), read your question and edit it to provide more detail. – Oded Apr 21 '12 at 08:35
  • when I am running it it's gave me this /protocol.rb:135:in 'sysread' (Errno:ECONNRESET) I am just new to ruby and dont know how to deal with this error – Dulos Adam Apr 21 '12 at 08:37
  • Please _edit_ your question to add details. – Oded Apr 21 '12 at 08:38

1 Answers1

0

Try changing the URL from http://stream.twitter.com/1/statuses/sample.json to https://stream.twitter.com/1/statuses/sample.json, the streaming API is only available via SSL nowadays (the Gist you linked to is a year old).

Michael Kohl
  • 66,324
  • 14
  • 138
  • 158
  • Thanks, but still have problem C:/Ruby187?lib/ruby/1.8/net/protocol.rb:135:in 'sysread':end of file reached (EOFError) – Dulos Adam Apr 21 '12 at 09:29
  • 1
    Why don't you just use a Twitter library instead of doing everything manually? https://github.com/intridea/tweetstream – Michael Kohl Apr 21 '12 at 09:38
  • I want to store tweets in Mongodb... – Dulos Adam Apr 21 '12 at 09:46
  • Who's stopping you? Use the gem I linked to above to retrieve the tweets and then use the MongoDB gem similar to the way it's used in the Gist to save them to Mongo. – Michael Kohl Apr 21 '12 at 11:22
  • which file I should use? There is so many files there – Dulos Adam Apr 21 '12 at 12:23
  • 1
    This is not how programming works. At one point you'll have to learn to solve your own problems. There's a reason this question was closed, it shows a definite lack of effort on your part. – Michael Kohl Apr 21 '12 at 14:38