This code keeps returning the 403 forbidden error. I have no clue how to fix this because all of the other examples I’ve looked at are for the v1.0 API. It says I need "Elevated access" to use this endpoint but I should be able to post a tweet with the essential access I have now. This is confusing and I would love some help!
import tweepy
consumer_key = 'consumer_key'
consumer_secret = 'consumer_secret'
access_token = 'access_token'
access_token_secret = 'access_token_secret'
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
api.update_status("first tweet")
2
Answers
Use
tweepy.Client
to access API v2 (nottweepy.API
)You can use following code:
You can see full step by step article here:
https://pythonhowtoprogram.com/how-to-build-a-twitter-bot-with-python-and-twitter-api-v2/