Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# Step 1: request and download your twitter archive
# Step 2: create a twitter app (on their dev site) so you can fill out the key and secret data
# Step 3: run, and prosper
require 'twitter'
require "json"
USERNAME = 'YOURUSERNAME'
ARCHIVE_PATH = '/YOUR/DOWNLOADS/FOLDER/data/js/tweets'
client = Twitter::REST::Client.new do |config|
config.consumer_key = '-set-'
config.consumer_secret = '-set-'
config.access_token = '-set-'
config.access_token_secret = '-set-'
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