The user timeline API neither return protected tweets nor proper error message

auth
api
authentication

#1

Hello,

I was using GET statuses/user_timeline API it was returning error with {}.
then i came to know that the tweets are protected. how would any one can guess the error reason with {} data. It should have proper error handling on REST API side.

Correct me if anything wrong. And let me know if there is any other way to get protected tweets of user.

Thank you :slight_smile:


Does Third party authorized application have access to private tweet? i have this issue
#2

Hi @Dhruv_Aerosol,

Were you getting a 200 response from the API? If so, the request/response transaction was valid, there was just no data that met the query provided.

User timelines belonging to protected users may only be requested when the authenticated user either “owns” the timeline or is an approved follower of the owner – as stated in the docs.

Hope this helps!


#3

@johnd thanks for the reply and Yeah, it’s getting 200 response, but also throws error with {}.
I am using npm twitter.

//Initialise twitter client object-Twitter with keys
var client = new Twitter({
    consumer_key: config.twitter.consumer_key,
    consumer_secret: config.twitter.consumer_secret,
    access_token_key: config.twitter.access_token_key,
    access_token_secret: config.twitter.access_token_secret
});
client.get('statuses/user_timeline', tparam, function (error, tweets, response) {
        if (error) {
          console.log("error : " + JSON.stringify(error)); // error: {} 
          // i am getting error here {}
        } else {
             //  data 
        }
});

I am using Auth, so user is giving permission to my app, giving rights to access protected tweets ? or if not can i add such permission?
i am not getting tweets.

  • if the Protect your tweet is true in setting i am getting 200 with error {}.
  • if the protect your tweet is false in setting i am getting 200 with tweets.

What to do in this case, Please explain.


#4

@johnd it’s been long time, can you please have look into it from your busy time?
if i also tried it using Postman , i get

{"request":"\/1.1\/statuses\/user_timeline.json","error":"Not authorized."}

and if any other error come it give error with code and message for example.

{"errors":[{"code":32,"message":"Could not authenticate you."}]}

why it’s not giving such in my case?


Why user timeline API returns differently in protected tweet response for this?