I am trying to use this code to delete 550 tweets from my account, as I want to use it as my personal account again without the tweets from my bots:
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)
But every time I run it, I get this error:
tweepy.error.TweepError: [{'message': 'Application cannot perform write actions. Contact Twitter Platform Operations through https://support.twitter.com/forms/platform', 'code': 261}]
When I print tweetid
, it is successfully grabbing all my tweets. I can also tweet normally using api.update_status
, so why is this not working? What am I doing wrong?
2
Answers
seems like you have made to many requests to the twitter api – from my little reasearch the error code 261 means the token was suspended. Check this links:
Why is the twitter API throwing this error?
https://blog.cotten.io/common-twitter-error-codes-6b324396042e
It sounds like your API key has been restricted (this can happen if you try to perform too many automated actions, see the automation rules 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