Skip to content

Instantly share code, notes, and snippets.

@chris-x86-64
Created June 23, 2013 07:20
Show Gist options
  • Save chris-x86-64/5844142 to your computer and use it in GitHub Desktop.
Save chris-x86-64/5844142 to your computer and use it in GitHub Desktop.
Very simple example of OAuth token request (Net::Twitter::Lite)
#!/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