Skip to content

Instantly share code, notes, and snippets.

@jeffa
Last active December 24, 2015 12:18
Show Gist options
  • Select an option

  • Save jeffa/6796458 to your computer and use it in GitHub Desktop.

Select an option

Save jeffa/6796458 to your computer and use it in GitHub Desktop.
Twitter APIs Client Library for Perl
#!/usr/bin/env perl
package LWP::Authen::OAuth2::Dancer;
our $VERSION = '0.1';
use Dancer ':syntax';
use Net::Twitter;
use Scalar::Util 'blessed';
our $nt = Net::Twitter->new(
traits => [qw/API::RESTv1_1/],
consumer_key => '',
consumer_secret => '',
access_token => '',
access_token_secret => '',
);
get '/' => sub { '<a href="/oauthauthorize">auth</a>' };
get '/oauthauthorize' => sub { redirect $nt->get_authorization_url( callback => 'http://www.example.com:3000/oauthcallback' ), 303 };
get '/oauthcallback' => sub { content_type 'text/plain'; to_yaml { params } };
package main;
use Dancer;
dance;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment