为什么我不能使用此代码删除多条推文? Python 二重奏

Why can't I delete multiple tweets with this code? Python tweepy

我正在尝试使用此代码从我的帐户中删除 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 正常发推文,为什么这不起作用?我做错了什么?

似乎您向 Twitter 发出了很多请求 api - 根据我的小调查,错误代码 261 表示令牌已暂停。检查此链接:

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

听起来您的 API 密钥已被限制(如果您尝试执行过多的自动化操作,可能会发生这种情况,请参阅自动化规则 https://help.twitter.com/en/rules-and-policies/twitter-automation). You will need to have the app restored via https://help.twitter.com/forms/automation