Hello everybody.
I’m using the standard (free version) of twitter’s API 1.1. I want to retrieve the tweets from an user with an specific hashtag, so Im using the method search from the API
Example to get user GAMEdigital with hashtag MassEffect
/1.1/search/tweets.json?q=from%3AGAMEdigital%20%23MassEffect
But I get this response:
{
“errors”: [
{
“code”: 32,
“message”: “Could not authenticate you.”
}
]
}
I know that this is not an authenticate problem, because I can search if I dont use standard operators with special characters.
I have tried the query with normal characters from: and encoded characters, from%A3 but nothing works so… How can I use standard operators that requiere special characters?
Thanks.
Error 32 means that you are probably having issues passing along the proper keys and tokens or authorizing your request. I suggest that you make sure to check the following:
- you are using the proper auth keys for this endpoint, which you can identify via the endpoint’s api reference page. It might help to review our authentication section for more details on this.
- you have properly generated the
oauth nonce , oauth_signature , and oauth_timestamp for your request.
If you have properly set up your keys and tokens, then chances are that you aren’t handling number two properly. If so, please consider using an oauth library (example), Insomnia, or try using Twurl.
As I said, this is not an authentication problem I can use the search call when if I dont use operator with special characters, or even other operations like user_timeline.
The problem is using special characters to search tweets from an user (from%3A) or search by hashtag (%23) because it triggers the error code 32
How can I use standard operators that requiere special characters?
The reason why it’s an authentication problem is because when using special characters in a request, sometimes there’s a mismatch between the call and the oauth signature base string - encoding the url parameters in the request is not enough, you also have to do it for the oauth headers https://developer.twitter.com/en/docs/basics/authentication/guides/creating-a-signature see the part about creating a signature base string.
Normally, the library you’re using in whatever language you’re coding in would do this for you - unless you’re implementing it from scratch. I wouldn’t recommend implementing this yourself - unless you’re looking to learn specifically about OAuth.
3 Likes
system
closed
#5
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
jrsyo
#6
@TestApi1.1 Just FYI, this might work for you.