Created
September 16, 2014 14:40
-
-
Save zachwhalen/36ff9caade7294606079 to your computer and use it in GitHub Desktop.
basicallytopgun.pl
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/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