Getting error "{"errors":[{"code":32,"message":"Could not authenticate you."}]}" while making call to twitter user timeline API

restapi
api-access

#1

Hi,

I have tried to pull the usertime line tweets for multiple screen names.

For the first time I have called the twitter API for one screenName and I got the data in 16 pages.
For the second time again I have called the twitter API with a different screenName and I got the data in only 4 pages but the API is keeping on retrying for the page 5 which has no data and it is entering into the infinite loop.

I got the below below mentioned error messages, It’s not even stopping until I kill it manually.

{“errors”:[{“code”:32,“message”:“Could not authenticate you.”}]}
{“errors”:[{“message”:“Rate limit exceeded”,“code”:88}]}

Parameters: count=3200&screen_name=McDonaldsCorp&Since_ID=“SOME VALUE”&page="pageno"
Logic: timestamp=date +%s
nonce=date +%s%T | openssl base64 | sed -e s'/[+=/]//g'
signature_base_string=“GET&https%3A%2F%2Fapi.twitter.com%2F1.1%2Fstatuses%2Fuser_timeline.json&oauth_consumer_key%3D${consumer_key}%26oauth_nonce%3D${nonce}%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D${timestamp}%26oauth_token%3D${oauth_token}%26oauth_version%3D1.0%26page%3D${pageNo}%26screen_name%3D${screen_name}%26since_id%3D${since_id}”

signature_key="${consumer_secret}&${oauth_secret}“
oauth_signature=echo -n ${signature_base_string} | openssl dgst -sha1 -hmac ${signature_key} -binary | openssl base64 | sed -e s'/+/%2B/' -e s'/\//%2F/' -e s'/=/%3D/'
header=“Authorization: OAuth oauth_consumer_key=”${consumer_key}”, oauth_nonce="${nonce}", oauth_signature="${oauth_signature}", oauth_signature_method=“HMAC-SHA1”, oauth_timestamp="${timestamp}", oauth_token="${oauth_token}", oauth_version=“1.0"”

curl --get “https://api.twitter.com/1.1/statuses/user_timeline.json” --data “screen_name=${screen_name}&page=${pageNo}&since_id=${since_id}” --header “Content-Type: application/x-www-form-urlencoded” --header “${header}” > ${screen_name}_$pageNo.json

How can I stop the API call if there is no data ?

Regards,
Aswin


#2

It’s likely an error in whatever library / code you’re using to make calls - maximum count in parameters should be 200, not 3200 - page parameter does not exist in timelines, only since_id and max_id - have a look at https://dev.twitter.com/rest/reference/get/statuses/user_timeline & https://dev.twitter.com/rest/public/timelines


#3

Thanks for your suggestion.

It’s is irrelevant to the error. You can see the page parameter in the example while generating OAuth Signature in twitter application.

My issue is If there is no data for the screen_name then it was retrying the twitter API until I kill it manually.
I would like to stop the API if there is no data.


#4

Would you please share the complete code you are using?