#!/usr/bin/perl
use Net::Twitter;
my $nt = Net::Twitter->new(
traits => ['API::RESTv1_1', 'OAuth'],
consumer_key => "YOUR-CONSUMER-KEY",
consumer_secret => "YOUR-CONSUMER-SECRET",
);
# You'll save the token and secret in cookie, config file or session database
my($access_token, $access_token_secret) = restore_tokens();
if ($access_token && $access_token_secret) {
$nt->access_token($access_token);
$nt->access_token_secret($access_token_secret);
}
unless ( $nt->authorized ) {
# The client is not yet authorized: Do it now
print "Authorize this app at ", $nt->get_authorization_url, " and enter the PIN#\n";
my $pin = <STDIN>; # wait for input
chomp $pin;
my($access_token, $access_token_secret, $user_id, $screen_name) = $nt->request_access_token(verifier => $pin);
save_tokens($access_token, $access_token_secret); # if necessary
}
sub restore_tokens {
}
sub save_tokens {
warn join "\n", @_, '';
}
Running this give:
Net::Twitter::Role::OAuth::get_authorization_url(): GET https://api.twitter.com/oauth/request_token failed: 401 Authorization Required at ./tw.pl line 20
Seems to be a recursive error (need to be authorized to get authorized). I did try with my apps keys just so you know.
Hi,
I tried using your example from https://metacpan.org/pod/Net::Twitter::Role::OAuth but the code dies on the get_authorization_url line:
Running this give:
Seems to be a recursive error (need to be authorized to get authorized). I did try with my apps keys just so you know.