voloko / twitter-stream

Twitter realtime API client
MIT License
233 stars 81 forks source link

Stream search API with track=#HASHTAG returns "401 Unauthorized" #14

Closed kou closed 13 years ago

kou commented 13 years ago

OAuth uses HTTP method, URL and request parameters to generate signature. So Twitter::JSONStream and SimpleOAuth::Header use the same request parameters. But the current code doesn't use the same request parameters. So request to http://stream.twitter.com/1/statuses/filter.json with track=#HASH_TAG request parameter and OAuth gets "401 Unauthorized".

Twitter::JSONStream#params returns escaped parameters and passes it to SimpleOAuth::Header. And SimpleOAuth::Header also escaped passed parameters. This is the problem. Twitter::JSONStream should pass not escaped parameters SimpleOAuth::Header.

Here is a sample code: stream_options = { :oauth => { ... }, :host => "stream.twitter.com", :path => "/1/statuses/filter.json", :method => "POST", :filters => "#twitter", } stream = Twitter::JSONStream.connect(stream_options) # this stream will get "401 Unauthorized"

FYI: Streaming API document: http://dev.twitter.com/pages/streaming_api_methods#statuses-filter

stve commented 13 years ago

+1 i've tested this and it's working well for me.