'Why is my Twitter bot not posting it's ".update_status"?
The code is simply intended for a test tweet and an error is returned. I am following a tutorial and they don't seem to be returning the same error. The tutorial is from May 2020 but the documentation for tweepy doesn't seem to have changed in these simple regards.
import tweepy
import time
consumer_key = 'xxx'
consumer_secret = 'xxx'
#bearertoken = "xxx"
access_token = 'xxx'
access_token_secret = 'xxx'
#authenticate to twitter
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
#create api object
api = tweepy.API(auth, wait_on_rate_limit=True)
##create tweet
api.update_status('1')
When the code tries to run it returns this error code.
Traceback (most recent call last):
File "/Users/thisaintyocompgetoff/Desktop/Twitterbot/twitterbot.py", line 16, in <module>
api.update_status('1')
File "/Users/thisaintyocompgetoff/Desktop/Twitterbot/tweepy/api.py", line 46, in wrapper
return method(*args, **kwargs)
File "/Users/thisaintyocompgetoff/Desktop/Twitterbot/tweepy/api.py", line 1128, in update_status
), status=status, **kwargs
File "/Users/thisaintyocompgetoff/Desktop/Twitterbot/tweepy/api.py", line 259, in request
raise Forbidden(resp)
tweepy.errors.Forbidden: 403 Forbidden
453 - You currently have Essential access which includes access to Twitter API v2 endpoints only. If you need access to this endpoint, you’ll need to apply for Elevated access via the Developer Portal. You can learn more here: https://developer.twitter.com/en/docs/twitter-api/getting-started/about-twitter-api#v2-access-leve
I do not have elevated access nor should I to post a test tweet. So I must be ignorant of some way to only send one request at a time. I have also checked to make sure the account does not have the tweet already posted.
Solution 1:[1]
The api.update_status endpoint is part of Twitter API v1.1. You only have access to Twitter API v2. You should use tweepy.Client.create_tweet() in order to hit the v2 endpoint.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Andy Piper |
