【发布时间】:2022-01-12 06:21:54
【问题描述】:
该代码仅用于测试推文并返回错误。我正在关注一个教程,他们似乎没有返回相同的错误。该教程从 2020 年 5 月开始,但 tweepy 的文档在这些简单的方面似乎没有改变。
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')
当代码尝试运行时,它会返回此错误代码。
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
我没有更高的访问权限,也不应该发布测试推文。所以我一定不知道一次只发送一个请求的某种方式。我还检查了该帐户是否已发布推文。
【问题讨论】: