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"
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