从我的命令行运行代码,得到此错误:
tweepy.error.TweepError:[{'code':93,'message':'此应用程序是 不允许访问或删除您的直接消息。'}]
...即使API密钥的权限设置为“读取,写入和直接消息”。
import tweepy
# Consumer keys and access tokens, used for OAuth
consumer_key = ''
consumer_secret = ''
access_token = ''
access_token_secret = ''
# Authenticate to Twitter
auth = tweepy.OAuthHandler(consumer_key,
consumer_secret)
auth.set_access_token(access_token,
access_token_secret)
api = tweepy.API(auth, wait_on_rate_limit=True, wait_on_rate_limit_notify=True)
try:
api.verify_credentials()
print("Authentication OK")
except:
print("Error during authentication")
messages = api.list_direct_messages()
print (messages)