Created
October 7, 2017 12:54
-
-
Save m3m0r7/12c33f9d8ae2838b1f531ce8a1755b6b to your computer and use it in GitHub Desktop.
Delete all your tweets
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
<?php | |
// Before step, `composer require abraham/twitteroauth` | |
// Run: `php cleaner.php` on your terminal | |
require __DIR__ . '/vendor/autoload.php'; | |
use Abraham\TwitterOAuth\TwitterOAuth; | |
$handle = fopen(__DIR__ . '/tweets.csv', 'r'); | |
$twitter = new TwitterOAuth( | |
'{CONSUMER_KEY}', | |
'{CONSUMER_SECRET}', | |
'{ACCESS_TOKEN}', | |
'{ACCESS_TOKEN_SECRET}'); | |
while ($row = fgetcsv($handle)) { | |
$tweetId = $row[0]; | |
if (!preg_match('\A[0-9]+\z', $tweetId)) continue; | |
printf('Deleting tweet %s', $tweetId); | |
$twitter->post('/statuses/destroy/' . $tweetId); | |
printf(" [DONE]\n"); | |
usleep(200); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment