Hey, I’m creating a twitter bot. I’m following a tutorial as I don’t have much dev experience in python. I encountered the following error
raise TweepError(error_msg, resp, api_code=api_error_code)tweepy.error.TweepError: [{'message': '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', 'code': 453}]
This is the code
import tweepy
import time
auth = tweepy.OAuthHandler('id','id')
auth.set_access_token('id','id')
api = tweepy.API(auth, wait_on_rate_limit=True, wait_on_rate_limit_notify=True)
user = api.me()
print(user)
I think the problem is quite clear in the error description
and if you are more experienced in javascript, why not use the javascript library?
In Tweepy, use the v2 API not the v1.1 API: Client — tweepy 4.10.1 documentation
2 Likes
I was able to solve the issue but for some unknown reason my account got limited. Maybe I exceeded the limit but I’m getting this error whenever I run the script.
[{'message': 'Application cannot perform write actions. Contact Twitter Platform Operations through https://help.twitter.com/forms/platform.', 'code': 261}]
It also says in my bot’s profile that my features have been limited because of violating twitter policies.
You can make an appeal on Platform.
If you believe your API access was restricted in error, explain why and give details of your usage.
Goodluck.
4 Likes
Could you share how you solved the issue? I’d be grateful for the solution
when I try this I get - AttributeError: module ‘tweepy’ has no attribute ‘Client’
This is usually a symptom of Tweepy being out of date,
pip install --upgrade tweepy
should work
I tried different ways but the same result.`
from requests_oauthlib import OAuth1
import requests
Set the API endpoint URL
url = “hhhhhhttps://api.twitter.com/1.1/statuses/update.json”
Set the POST parameters
params = {“status”: “Hello, world!”}
Set the OAuth credentials
consumer_key =api_key
consumer_secret =api_key_secret
access_token = access_token
access_token_secret = access_token_secret
Set up the OAuth authentication
oauth = OAuth1(consumer_key,
client_secret=consumer_secret,
resource_owner_key=access_token,
resource_owner_secret=access_token_secret)
Send the POST request
response = requests.post(url, params=params, auth=oauth)
Print the response
print(response.json())
`
You are calling a v1.1 API with requests library it looks like? Not with tweepy, but anyway, you need Elevated Access to make calls to v1.1 and to post tweets you need write permissions in the access token (this is a setting in the app settings, and tokens must be reset after it changes)
1 Like