Rev | Line | |
---|
[c78c702] | 1 | #!/usr/bin/env perl |
---|
| 2 | use strict; |
---|
| 3 | use warnings; |
---|
| 4 | use utf8; |
---|
[2d5b749] | 5 | use Net::Twitter::Lite; |
---|
[c78c702] | 6 | |
---|
[1680a86] | 7 | use YAML::Tiny; |
---|
| 8 | my $config = (YAML::Tiny->read('config.yml'))->[0]; |
---|
| 9 | |
---|
| 10 | my $consumer_key = $config->{'consumer_key'}; |
---|
[d006afb] | 11 | my $consumer_key_secret = $config->{'consumer_secret'}; |
---|
[1680a86] | 12 | my $access_token = $config->{'access_token'}; |
---|
| 13 | my $access_token_secret = $config->{'access_token_secret'}; |
---|
[c78c702] | 14 | |
---|
[2d5b749] | 15 | my $nt = Net::Twitter::Lite->new( |
---|
[c78c702] | 16 | traits => ['API::REST', 'OAuth'], |
---|
| 17 | consumer_key => $consumer_key, |
---|
| 18 | consumer_secret => $consumer_key_secret, |
---|
| 19 | ); |
---|
| 20 | print 'access this url by bot account : '.$nt->get_authorization_url."\n"; |
---|
| 21 | print 'input verifier PIN : '; |
---|
| 22 | my $verifier = <STDIN>; |
---|
| 23 | chomp $verifier; |
---|
| 24 | |
---|
| 25 | my $token = $nt->request_token; |
---|
| 26 | my $token_secret = $nt->request_token_secret; |
---|
| 27 | |
---|
| 28 | $nt->request_token($token); |
---|
| 29 | $nt->request_token_secret($token_secret); |
---|
| 30 | |
---|
| 31 | my($at, $ats) = $nt->request_access_token(verifier => $verifier); |
---|
| 32 | |
---|
| 33 | print "Access token : ".$at."\n"; |
---|
| 34 | print "Access token secret : ".$ats."\n"; |
---|
Note: See
TracBrowser
for help on using the repository browser.