Skip to content

Instantly share code, notes, and snippets.

@m3m0r7
Created October 7, 2017 12:54
Show Gist options
  • Save m3m0r7/12c33f9d8ae2838b1f531ce8a1755b6b to your computer and use it in GitHub Desktop.
Save m3m0r7/12c33f9d8ae2838b1f531ce8a1755b6b to your computer and use it in GitHub Desktop.
Delete all your tweets
<?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