#!/usr/local/bin/perl
use strict;
use warnings;
use Net::Twitter;
use Net::Twitter::Error;
use Scalar::Util 'blessed';
$|++;
#Mass Tweet deletion
my %nt_settings =
(
consumer_key => '',
consumer_secret => '',
access_token => '',
access_token_secret => '',
traits => [qw/OAuth API::REST RetryOnError InflateObjects/],
max_retries => 3,
ssl => 1,
decode_html_entities => 1,
);
my $nt = Net::Twitter->new(%nt_settings);
while(1)
{
my $statuses = eval
{
$nt->user_timeline
({
screen_name => '',
include_rts => 'true',
include_entities => 'true',
count => 200,
})
};
if ( my $err = $@ )
{
if(blessed $@ && $err->isa('Net::Twitter::Error'))
{
warn "HTTP Response Code: ", $err->code, "\n",
"HTTP Message......: ", $err->message, "\n",
"Twitter error.....: ", $err->error, "\n";
}
else
{
die $@;
}
}
my @ids = ();
for my $status ( @$statuses )
{
push(@ids, $status->id);
}
foreach my $id(@ids)
{
print "$id\n";
my $statuses = eval {$nt->destroy_status({id => $id})};
if ( my $err = $@ )
{
if(blessed $@ && $err->isa('Net::Twitter::Error'))
{
warn "HTTP Response Code: ", $err->code, "\n",
"HTTP Message......: ", $err->message, "\n",
"Twitter error.....: ", $err->error, "\n";
}
else
{
die $@;
}
}
}
print "Continuing...\n";
}
0 comments:
Post a Comment