Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * @author Wolfgang ten Weges
- * @desc script de suppression de tweets.
- */
- require('lib/tmhOAuth.php');
- //if we flood the API, it'll throttle or block us, so be careful.
- define("TIME_BETWEEN_API_CALLS", 5);
- $twitterAuth = array( //account parameters
- 'consumer_key' => 'xxxxxxxxxxxx',
- 'consumer_secret' => 'xxxxxxxxxxx',
- 'user_token' => 'xxxxxxx-xxxxxxxx',
- 'user_secret' => 'xxxxxxxxxxxxxx',
- );
- $oa = new tmhOAuth( $twitterAuth );
- $re = fopen("tweets.csv", 'r'); //file gotten from https://twitter.com/settings/account
- while( $ligne = fgetcsv($re) ) {
- $id = $ligne[0];
- //skim throught the cvs file until we reach the desired point
- //alternatively, you could use for($a=0 ; $a < NB ; $a++) { fgetcsv($re); } to skip the NB first tweets
- if($id > xxxxxxxx) continue;
- $http_code = $oa->request(
- 'POST',
- $oa->url("1.1/statuses/destroy/$id"),
- array(
- 'id' => $id,
- 'include_entities' => 'false',
- 'trim_user' => 'true',
- )
- );
- //404 = not found ; 503 = service unavailable (temporaire/rare, donc passe au suivant plutot qu'arreter le script)
- if ($http_code != 200) {
- echo "\n[EE] error while deleting";
- if( $http_code == '404' || $http_code == '503') {
- echo "\n $http_code";
- continue;
- }
- echo "\n\n";
- print_r($oa->response['info']);
- break;
- }
- echo "\n$id ".$ligne[5];
- sleep(TIME_BETWEEN_API_CALLS); //pause pour pas flood
- }
- echo "\nfin\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement