Forked from kirillzubovsky/How to delete all tweets with Ruby fast
Last active
July 25, 2019 07:17
-
-
Save Braeden-Mayer/0bd36c52fae1d7cff5aa to your computer and use it in GitHub Desktop.
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
require 'twitter' | |
require "json" | |
USERNAME = 'YOUR_TWITTER_USER_NAME' | |
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('PATH_TO_TWEET_ARCHIVE') do |item| | |
unless (item == '.') or (item == '..') or (item == '.DS_Store') | |
#ignore system files and paths | |
file = File.readlines("PATH_TO_TWEET_ARCHIVE/#{item}")[1..-1].join() | |
data = JSON.parse(file) | |
data.each do |tweet| | |
removeId = tweet['id'] | |
tweetDate = tweet['created_at'] | |
begin | |
client.destroy_status(removeId) | |
puts "Destroyed tweet_id: #{removeId} tweet_date: #{tweetDate}" | |
rescue => e | |
puts "Error: #{e} -- tweet_id: #{removeId} tweet_date: #{tweetDate}" | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment