HTTP ERROR: 401 only on stream.twitter.com


#1

Hi everyone,

I’m trying to get my Adobe Air (actionscript3) app working with the twitter API. I’m using the susisu twitter library.

I’m aiming to use ‘/1.1/statuses/filter.json’ to get a stream of the members of a list. To do this I first check the credentials at ‘https://api.twitter.com/1.1/account/verify_credentials.json’. This works.
After that, I call up the list members. Works fine as well. I receive all the members and their information, no problem. These requests are all send by GET.
But when I then send a request to ‘https://stream.twitter.com/1.1/statuses/filter.json’ using the POST method and it just returns:

Error 401 Unauthorized

HTTP ERROR: 401

Problem accessing '/1.1/statuses/filter.json'. Reason:

    Unauthorized
*white space*

I don’t understand what’s going on? Somehow my post method is wrong somewhere, but I don’t see it…

The headers used for streaming:
OAuth oauth_signature=“4ZfBhNwqiRoFoetG0pAejznNYTc%3D”,oauth_version=“1.0”,oauth_timestamp=“1375273532”,oauth_nonce=“xxxxx”,oauth_token="xxxxxxx-xxxxxxxxxx ",oauth_signature_method=“HMAC-SHA1”,oauth_consumer_key=“xxxxx”

If I try to fetch data from api.twitter.com using POST it simply won’t respond at all. Is this normal?
These are the POST headers for that request:

OAuth oauth_version=“1.0”,oauth_token=“xxxxxxxx-xxxxxxxxxxxx”,oauth_nonce=“xxxxxxxxxx”,oauth_signature_method=“HMAC-SHA1”,oauth_signature=“UbYR7gAipsV6vo2oj1FB1SBzDOU%3D”,oauth_timestamp=“1375274591”,oauth_consumer_key="xxxxxxxxxx"
Data: include_entities=true&list_id=93216508&skip_status=true

I already checked the system time. No problems there.
I hope someone can help me out :confused: If you need any more information please ask.


#2

I’m unfortunately unfamiliar with AIR, but perhaps there is something else that your framework is sending in such requests that is causing an issue? Are there are any additional HTTP headers attached by your environment that might conflict with your credentials?

Are you encoding the characters of your track parameter correctly? Be especially careful with commas.


#3

What’s the signature base string you’re creating? The HTTP method is part of that string, so if GET works but POST doesn’t, I’d expect that maybe the method was not being updated in the signature generation code.


#4

He this could be something! I was sending the follow parameters as clear text, just comma separated. I tried with just 1 ID, and i got a HTTP 200.
I fiddled around somewhat in the library code, and got it to encode the query, now I get the HTTP 200 status even when asking 30 ID’s

Many, many thanks!

edit:

That was it! I’m receiving the stream now! \0/