Changeset 6da7e2a in lab.git for twitter/show_status.pl
- Timestamp:
- Oct 2, 2010 10:02:23 PM (14 years ago)
- Branches:
- master, trunk
- Children:
- b4d59be
- Parents:
- 439448c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
twitter/show_status.pl
r035465b r6da7e2a 11 11 ## from http://search.cpan.org/perldoc?Net::Twitter::Lite#ERROR_HANDLING 12 12 use Net::Twitter::Lite; 13 use FindBin qw($Bin); 14 use YAML::Tiny; 13 use Data::Dumper; 15 14 16 my $conf = loadconf("$Bin/config.yml"); 17 if (! defined $conf) { 18 die "$0: cannot parse config file.\n"; 19 } 20 21 my $bot = login($conf); 22 if (! $bot->authorized) { 23 die "$0: this client is not yet authorized.\n"; 24 } 25 15 my $bot = Net::Twitter::Lite->new; 26 16 27 17 eval { 28 18 foreach my $id (@ARGV) { 29 19 my $res = $bot->show_status($id); 30 use Data::Dumper;31 20 foreach my $line (split /\n/, Dumper $res) { 32 21 if ($line =~ /undef/) { next; } … … 51 40 52 41 53 sub loadconf {54 # load configration data from yaml formatted file55 # param => scalar string of filename56 # ret => hash object of yaml data57 58 my $file = shift @_;59 60 my $yaml = YAML::Tiny->read($file);61 62 if ($!) {63 warn "$0: '$file' $!\n";64 }65 66 return $yaml->[0];67 }68 69 sub login {70 # make Net::Twitter::Lite object and login71 # param => hash object of configration72 # ret => Net::Twitter::Lite object73 74 my $conf = shift @_;75 76 my $bot = Net::Twitter::Lite->new(77 consumer_key => $conf->{consumer_key},78 consumer_secret => $conf->{consumer_secret},79 );80 81 $bot->access_token($conf->{access_token});82 $bot->access_token_secret($conf->{access_token_secret});83 84 return $bot;85 }86 87 42 sub evalrescue { 88 43 # output error message at eval error
Note: See TracChangeset
for help on using the changeset viewer.