Skip to content

Instantly share code, notes, and snippets.

@semifor
Created August 10, 2011 20:59
Show Gist options
  • Select an option

  • Save semifor/1138248 to your computer and use it in GitHub Desktop.

Select an option

Save semifor/1138248 to your computer and use it in GitHub Desktop.
Simple OAuth test for DM access
#!/usr/bin/env perl
use Modern::Perl;
use Net::Twitter;
my $nt = Net::Twitter->new(
traits => [qw/OAuth API::REST RetryOnError/],
consumer_key => 'MkkW2yJ2H1WTWhOIWlw',
consumer_secret => '0oWd3jArJrEFOHUZu6b6NAsJShZoDiDtaLJCmrzdu8',
);
printf "Authorize app at %s\nthen, eter the PIN#: ", $nt->get_authorization_url;
my $pin = <STDIN>;
chomp $pin;
my @oauth = $nt->request_access_token(verifier => $pin);
my $r = $nt->direct_messages;
printf "success: %d direct messages read\n", scalar @$r;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment