I’m trying to get tweets using Twitter API like this:
https://api.twitter.com/1.1/statuses/user_timeline/user_timeline.json?screen_name=username&count=2
But only when I go to that page, it returns the following:
{“errors”:[{“code”:215,”message”:”Bad Authentication data.”}]}
I haven’t found something additional or special which I should have added to the request on their documentation here https://developer.twitter.com/en/docs/tweets/timelines/api-reference/get-statuses-user_timeline.html
Is anyone investigated it earlier? I’d be very pleased if you shared how did you do that.
3
Answers
I had to download their php ini file, which sends a request to the twitter domain and approves my website.
Twitter’s API does not allow access without authentication via OAuth!
Unauthenticated access is discontinued permanently.
Check this out: https://developer.twitter.com/en/docs/basics/authentication/guides/authorizing-a-request
Another guide that worked for me:
https://tomelliott.com/php/authenticating-twitter-feed-timeline-oauth
You need to go on the Twitter developers page and set up an App. You will not use it as an app, you only need the access keys. Then your code should begin like this: (I am using tweepy)