Last active
July 4, 2023 07:39
-
-
Save kirillzubovsky/6333f09f3d557397dc6f to your computer and use it in GitHub Desktop.
A quick way to delete all your tweets using Twitter archive and a ruby script.
This file contains hidden or 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
require 'twitter' | |
require "json" | |
USERNAME = 'YOUR_TWITTER_USER_NAME' | |
ARCHIVE_PATH = 'archive/data/js/tweets' | |
client = Twitter::REST::Client.new do |config| | |
config.consumer_key = 'TWITTER_APP_API_KEY' | |
config.consumer_secret = 'TWITTER_APP_API_SECRET' | |
config.access_token = 'TWITTER_APP_ACCESS_TOKEN' | |
config.access_token_secret = 'TWITTER_APP_ACCESS_TOKEN_SECRET' | |
end | |
Dir.foreach(ARCHIVE_PATH) do |item| | |
unless (item == '.') or (item == '..') or (item == '.DS_Store') | |
#ignore system files and paths | |
file = File.readlines("#{ARCHIVE_PATH}/#{item}")[1..-1].join() | |
data = JSON.parse(file) | |
data.each do |tweet| | |
removeId = tweet['id'] | |
begin | |
client.destroy_status(removeId) | |
puts "destroyed tweet_id: #{removeId}" | |
rescue => e | |
puts "ooops: #{e} -- t_id: #{removeId}" | |
end | |
end | |
sleep(60) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@Rishi333 good point. I will rework it to be more obvious.