Created
June 23, 2013 07:20
-
-
Save chris-x86-64/5844142 to your computer and use it in GitHub Desktop.
Very simple example of OAuth token request (Net::Twitter::Lite)
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/perl | |
use strict; | |
use warnings; | |
use feature 'say'; | |
use Net::Twitter::Lite::WithAPIv1_1; | |
use YAML::Syck; | |
use Data::Dumper; | |
my $conf = YAML::Syck::LoadFile('config.yml')->{oauth}; | |
print Dumper($conf); | |
my $nt = Net::Twitter::Lite::WithAPIv1_1->new( | |
consumer_secret => $conf->{consumer_secret}, | |
consumer_key => $conf->{consumer_key}, | |
access_token => $conf->{access_token}, | |
access_token_secret => $conf->{access_token_secret} | |
); | |
if (!$nt->authorized) { | |
say $nt->get_authorization_url; | |
print "PIN: "; | |
my $pin = <STDIN>; | |
chomp $pin; | |
print Dumper($nt->request_access_token(verifier => $pin)); | |
} else { | |
say "Authorized!"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment