Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- #
- # Net::Twitter - OAuth desktop app example
- #
- use warnings;
- use strict;
- use Net::Twitter;
- my $consumer_key = shift;
- my $consumer_secret = shift;
- if (!$consumer_key or !$consumer_secret) {
- print "\nUsage: ".$0." consumer_key consumer_secret\n\n";
- exit 1;
- }
- my %consumer_tokens = (
- consumer_key => $consumer_key,
- consumer_secret => $consumer_secret,
- );
- my $nt = Net::Twitter->new(traits => [qw/API::REST OAuth/], %consumer_tokens);
- my $auth_url = $nt->get_authorization_url;
- print "Authorize this application at: $auth_url\nThen, enter the PIN# provided to continue: ";
- my $pin = <STDIN>; # wait for input
- chomp $pin;
- my @access_tokens = $nt->request_access_token(verifier => $pin);
- if (@access_tokens) {
- print "Access Token : ".$access_tokens[0]."\n";
- print "Access Token Secret : ".$access_tokens[1]."\n";
- print "Twitter User ID : ".$access_tokens[2]."\n";
- print "Twitter Username : ".$access_tokens[3]."\n";
- } else {
- print "I dont get any access token :(\n";
- }
- print "\n";
Add Comment
Please, Sign In to add comment