Created
September 17, 2010 08:09
-
-
Save keiya/583909 to your computer and use it in GitHub Desktop.
Delete your twitter posts
This file contains 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
#!/usr/bin/perl | |
# Cf. http://d.hatena.ne.jp/famnet/20100917/1284711061 | |
use strict; | |
use warnings; | |
use lib './lib'; | |
use LWP; | |
use LWP::ConnCache; | |
use Net::Twitter; | |
require 'authtwitter'; | |
$| = 1; | |
my $nt = Net::Twitter->new( | |
traits => ['API::REST', 'OAuth'], | |
consumer_key => 'CONSUMER_KEY', | |
consumer_secret => 'CONSUMER_SECRET', | |
); | |
$nt->access_token('AUTH_TOKEN'); | |
$nt->access_token_secret('AUTH_TOKEN_SECRET'); | |
my $i=0; | |
while (1) { | |
my $statuses_ref = $nt->user_timeline({page=>$i,}); | |
my @ids = &parse(@$statuses_ref); | |
foreach my $tweet (@ids) { | |
my $res = $nt->destroy_status($tweet); | |
if (defined $res) { | |
print $res."\n"; | |
sleep 5; | |
} else { | |
print "failed\n"; | |
next; | |
} | |
} | |
$i++; | |
sleep 5; | |
sleep 10 if $i % 30 == 0; | |
} | |
sub parse { | |
my @ids; | |
foreach my $hash_ref (@_) { | |
my $tweet_id = $hash_ref->{'id'}; | |
push(@ids,$tweet_id); | |
} | |
return @ids; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment