I want to get a Tweets list using GET statuses/home_timeline. My Resource URL without any additional parameters. When I send a request, I get the error Forbidden. A part of of code below
public async Task<BindableCollection<Tweet>> Execute()
{
string uri = "https://api.twitter.com/1.1/statuses/home_timeline.json";
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Add("Host", "api.twitter.com");
client.DefaultRequestHeaders.Add("Authorization", info.TokenType + ' ' + info.AccessToken);
HttpResponseMessage responce = new HttpResponseMessage();
while (true)
{
try
{
responce = await client.GetAsync(uri);
break;
}
catch { Debug.WriteLine("ERROR!"); }
}
info.TokenType
and info.AccessToken
contain “bearer” and my access token
in accordance.
Appropriate photo
When I sent the request (GET statuses / USER_timeline) with this parameters (TokenType and AccessToken)I got the correct answer.
Any ideas on this?
3
Answers
HOME_timeline requires user authentication as opposed to application authentication, which can be used with User_timeline. Are you authenticated using application credentials perchance?
From the docs:
“With Application-only authentication you don’t have the context of an authenticated user and this means that any request to API for endpoints that require user context, such as posting tweets, will not work. However, the set of endpoints that will still be available can have a higher rate limit.”
As Ian Nelson said you need an authorization to access to your timeline. But you can use LinqToTwitter for getting a list of tweets.
you need to differentiate HomeTimeline and UserTimeline.
Tweetinvi gives a very straight access to both of these :
Timeline documentation
For authentication you will also need 1 line:
Authentication documentation
Let me know if this is of any help.