为什么我不能用这个代码删除多条推文?Python花

2024-05-14 18:35:00 发布

您现在位置:Python中文网/ 问答频道 /正文

我正试图使用此代码从我的帐户中删除550条推文,因为我想再次将其用作我的个人帐户,而不必使用我的机器人程序的推文:

import tweepy
import json

auth = tweepy.OAuthHandler("consumer_key", "consumer_secret")

auth.set_access_token("access_token", "access_token_secret")

api = tweepy.API(auth)

screen_name = "YOUR_TWITTER_HANDLE"

timelines = api.user_timeline(screen_name, count = 550, include_rts = False)

for status in timelines:
    tweetid = status._json
    api.destroy_status(tweetid)

但每次我运行它时,都会出现以下错误:

tweepy.error.TweepError: [{'message': 'Application cannot perform write actions. Contact Twitter Platform Operations through https://support.twitter.com/forms/platform', 'code': 261}]

当我打印tweetid时,它成功地抓取了我所有的推文。我也可以正常使用api.update_status发tweet,为什么这不起作用呢?我做错了什么


Tags: nameimporttokenauthapijsonsecretaccess
2条回答

听起来您的API密钥受到了限制(如果您尝试执行太多的自动化操作,则可能会发生这种情况,请参阅自动化规则https://help.twitter.com/en/rules-and-policies/twitter-automation)。您需要通过https://help.twitter.com/forms/automation还原应用程序

看起来您已经向twitter api发出了很多请求-从我的小搜索中,错误代码261表示令牌被挂起。检查以下链接:

Why is the twitter API throwing this error?

https://blog.cotten.io/common-twitter-error-codes-6b324396042e

相关问题 更多 >

    热门问题