Skip to content

Instantly share code, notes, and snippets.

@kylebragger
Created October 23, 2017 20:59
Show Gist options
  • Save kylebragger/92300e7c053fd2843d8a518d548e45ae to your computer and use it in GitHub Desktop.
Save kylebragger/92300e7c053fd2843d8a518d548e45ae to your computer and use it in GitHub Desktop.
# 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