Hubot
    
    
  
  
  
view release on metacpan or search on metacpan
lib/Hubot/Scripts/tweet.pm view on Meta::CPAN
    my $client = AnyEvent::HTTP::ScopedClient->new(
        'https://api.twitter.com/oauth2/token',
        options => {
            auth => uri_escape( $ENV{HUBOT_TWITTER_CONSUMER_KEY} ) . ':'
                . uri_escape( $ENV{HUBOT_TWITTER_CONSUMER_SECRET} )
        }
    );
    $client->post(
        { grant_type => 'client_credentials' },
        sub {
            my ( $body, $hdr ) = @_;
            return if !$body;
            my $data = decode_json($body);
            if ( $hdr->{Status} =~ /^2/ ) {
                my ( $token_type, $access_token )
                    = ( $data->{token_type}, $data->{access_token} );
                $authorization = ucfirst $token_type . " $access_token";
( run in 0.855 second using v1.01-cache-2.11-cpan-c333fce770f )