Skip to content

Instantly share code, notes, and snippets.

@zachwhalen
Created September 16, 2014 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zachwhalen/36ff9caade7294606079 to your computer and use it in GitHub Desktop.
Save zachwhalen/36ff9caade7294606079 to your computer and use it in GitHub Desktop.
basicallytopgun.pl
#!/usr/bin/local/perl
use Net::Twitter;
$prefix = '/home/zach/Software/pg/power';
# make a list of all the frames
@frames = glob "$prefix/frames/*.png";
# select the first one from that list, to be tweeted.
$frame = $frames[0];
# set up Twitter object
my $nt = Net::Twitter->new(
traits => [qw/API::RESTv1_1/],
consumer_key => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
consumer_secret => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
access_token => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
access_token_secret => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
ssl => 1
);
# create the media array to include frame
# (I don't know why Net::Twitter expects this to be an array reference)
my @media = ("$frame");
# send the tweet with image messages
my $status = $nt->update_with_media(" ", \@media);
# Error messages if it didn't work
if ( my $err = $@ ) {
die $@ unless blessed $err && $err->isa('Net::Twitter::Error');
warn "HTTP Response Code: ", $err->code, "\n",
"HTTP Message......: ", $err->message, "\n",
"Twitter error.....: ", $err->error, "\n";
}
# move that just-posted image into the "done" pile
system("mv $frame $prefix/posted/");
exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment