pythontweepytwitterapi-python

Twitter API v2 and v1.1


so i want to use tweepy in order to post some tweets ( photos, and videos basically) and i am just using the free versin of the twitter developer account. I know there are some limitaion, and by searching in the internet I got confused and I do not know if it has changed or what, but whenever I try to fetch some data or post it i get this error:

tweepy.errors.Forbidden: 403 Forbidden 453 - You currently have access to a subset of Twitter API v2 endpoints and limited v1.1 endpoints (e.g. media post, oauth) only. If you need access to this endpoint, you may need a different access level. You can learn more here: https://developer.twitter.com/en/portal/product

My code is the one below :

auth = tweepy.OAuth1UserHandler(
   consumer_key= API_KEY,
    consumer_secret= API_KEY_SECRET,
    access_token= ACCESS_TOKEN,
    access_token_secret=ACCESS_TOKEN_SECRET,
)
api = tweepy.API(auth)

media_file_path = "Downloaded_Files\ 2023_11_27\IMG_8018.PNG"

# Upload media
media = api.simple_upload(media_file_path)

#Post a tweet with the uploaded media
tweet_text = 'Check out this media!'
api.update_status(status=tweet_text, media_ids=[media.media_id])

I tried to use different authentification methods using tweepy.Client also but it did not work


Solution

  • The free tier only allows creating tweets. I guess you can't upload media with it.