Trying to parse stream.twitter.com, please help.

J

Jesse Crockett

I'm having no luck working on this, and it's my first attempt at such a
process. Here is the code as it is now. When I run the file, I'm
testing it against my own twitter account, and I see in the '% Received'
it gets about 1100 bytes each time I update, but nothing else works
beyond that.

This is a job qualifier, any help is appreciated.
Code:
require "rubygems"
require "json"

BASE = "http://stream.twitter.com/"
MODE = "follow.json"
USER = "-u----------:-------"

USERS = [26079932]


IO.popen("curl -d @following #{BASE}#{MODE} #{USER}") do |io|
begin
while line = io.gets
status = line.length > 2 ? JSON.parse(line) : nil
if status
if status["user"]["screen_name"] == 'my_screen_name'
File.new("update_file", 'a').puts "hello"
#`echo \"#{status[:user][:id]}\" >> update_file`
end
end
end
rescue
# connection lost
end
end
 
J

John W Higgins

[Note: parts of this message were removed to make it a legal post.]

My god how low has the world gotten - it's one thing for a kid to beg for
code to get a high school grade in a class they probably don't care about -
but when an adult actually sticks up their hand in a room of professionals
and begs for assistance to cheat a company out of money what the hell have
we become. If you cannot perform the job (and can't even figure out how to
google the answer at least) then please have the decency to not steal the
time and money of the company who you are trying to steal from.

John W Higgins
 
J

Jesse Crockett

A man of such integrity as John W Higgins would surely code in the
middle of Wichita for $10/hr and have an open case with SRS Vocational
Rehab. How about it, Higgs?
 
J

John W Higgins

[Note: parts of this message were removed to make it a legal post.]

My sincerest sympathy (I can't think of a better term here but I mean no
disrespect), on whatever condition/situation placed you in the situation
that required any form of rehab.

However, clearly if one looked at your original request it's a very
different situation then what you now state. Maybe in the future when you
make a request that clearly could be viewed as a negative request you'll put
a little more context around it so it doesn't look like you are doing
something dishonest.

Best of luck to you and your family!

John W Higgins
 
R

Rilindo Foster

FWIW, why are you trying to use an external process within the ruby
script?

A cursory search in twitter's and in google will tell you that you
should be able to parse the stream directly. Look up open-uri docs -
that should get you someplace.
 
J

Jesse Crockett

Finally made some progress, which means one less grudge :) I'm
guessing this thread will get some traffic in the near future, so I'm
posting what I believe is a good starting block. While it's not a
parsing solution, it should aim in the right direction.

require 'rubygems'
require 'json'

BASE_URL = "http://stream.twitter.com/spritzer.json"
USER = "-uuser_name:password"

File.open("update_file", "a") do |f|
IO.popen("curl #{BASE_URL} #{USER}") do |p|
p.each do |status|
f.puts status
end
end
end
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top