I am facing very strange and frustrating error.
After generating a successful accessToken through OAuth dance, I try
to retrieve "friends_timeline" using this ruby snippet:
<code>
resp = accessToken.get("/1/statuses/friends_timeline.json?
count=300&since_id=#{lastid}&include_rts=true")
</code>
where lastid is read from a persistent storage.
But when run as part of a ruby script, it gives the "WRONG STATUS
LINE" error:
--------
/usr/local/lib/ruby/1.9.1/net/http.rb:2138:in `read_status_line':
wrong status line: "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0
Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-
transitional.dtd\">" (Net::HTTPBadResponse)
        from /usr/local/lib/ruby/1.9.1/net/http.rb:2125:in `read_new'
        from /usr/local/lib/ruby/1.9.1/net/http.rb:1117:in
`transport_request'
        from /usr/local/lib/ruby/1.9.1/net/http.rb:1103:in `request'
        from /usr/local/lib/ruby/1.9.1/net/http.rb:1096:in `block in request'
        from /usr/local/lib/ruby/1.9.1/net/http.rb:564:in `start'
        from /usr/local/lib/ruby/1.9.1/net/http.rb:1094:in `request'
        from /usr/local/lib/ruby/gems/1.9.1/gems/oauth-0.4.2/lib/oauth/
consumer.rb:164:in `request'
        from /usr/local/lib/ruby/gems/1.9.1/gems/oauth-0.4.2/lib/oauth/tokens/
consumer_token.rb:25:in `request'
        from /usr/local/lib/ruby/gems/1.9.1/gems/oauth-0.4.2/lib/oauth/tokens/
access_token.rb:11:in `request'
        from /usr/local/lib/ruby/gems/1.9.1/gems/oauth-0.4.2/lib/oauth/tokens/
access_token.rb:24:in `get'
        from ~/src/my_FTL.rb:21:in `<main>'
-------
Surprisingly, if i remove the "&since_id=#{lastid}" part and run the
same script, it works successfully.
More surprisingly, when i run the same line in irb (after putting in
the instructions before that line), it runs fine even with "since_id="
parameter.

It is puzzling what causes the error. Since it is a BadResponse error,
it looks like generated from Twitter servers, but only as a response
to a request that could be different from the one working successfully
from irb. On the other hand, inclusion of "since_id" in the script
must be generating an unservable request??
Any insights on how to fix it would be appreciated as I have to
migrate to OAuth quickly.

Thanks

Reply via email to