Last active
August 15, 2024 20:34
-
-
Save harryawk/706d44ed80ca24d22d8a52987ab54ab5 to your computer and use it in GitHub Desktop.
Script to delete all your tweets and replies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This script is using python-twitter SDK (https://github.com/bear/python-twitter) | |
All key and secret strings can be generated by creating an app in https://apps.twitter.com/ | |
""" | |
import twitter | |
consumer_key = '' | |
consumer_secret = '' | |
access_token_key = '' | |
access_token_secret = '' | |
api = twitter.Api( | |
consumer_key=consumer_key, | |
consumer_secret=consumer_secret, | |
access_token_key=access_token_key, | |
access_token_secret=access_token_secret | |
) | |
# Delete own tweets | |
owned_status = api.GetUserTimeline(count=200) | |
num_owned_status = 0 | |
while(len(owned_status) > 0): | |
for s in owned_status: | |
api.DestroyStatus(s.id) | |
print('One tweet deleted') | |
num_owned_status += 1 | |
owned_status = api.GetUserTimeline(count=200) | |
print('Your ' + str(num_owned_status) + ' tweets has been deleted.') | |
# Delete replies | |
owned_replies = api.GetReplies(count=200) | |
num_owned_replies = 0 | |
while(len(owned_replies) > 0): | |
for s in owned_replies: | |
api.DestroyStatus(s.id) | |
print('One reply deleted') | |
num_owned_replies += 1 | |
owned_replies = api.GetReplies(count=200) | |
print('Your ' + str(num_owned_replies) + ' replies has been deleted.') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment