-
-
Save cutmail/1862779 to your computer and use it in GitHub Desktop.
Twitter activity API test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use Config::Pit; | |
use Data::Dumper; | |
use Furl; | |
use HTTP::Request::Common; | |
use JSON::XS 'decode_json'; | |
use OAuth::Lite::Consumer; | |
my $config = pit_get('twitter.com', require => { | |
consumer_key => 'consumer_key', | |
consumer_secret => 'consumer_secret', | |
access_token => 'access_token', | |
access_token_secret => 'access_token_secret', | |
}); | |
my $consumer = OAuth::Lite::Consumer->new( | |
consumer_key => $config->{consumer_key}, | |
consumer_secret => $config->{consumer_secret}, | |
); | |
my $uri = 'http://api.twitter.com/i/activity/about_me.json'; | |
my $req = GET $uri, | |
Authorization => $consumer->gen_auth_header('GET', $uri, +{ | |
token => OAuth::Lite::Token->new( | |
token => $config->{access_token}, | |
secret => $config->{access_token_secret}, | |
), | |
}); | |
my $res = Furl->new->request($req); | |
if ($res->is_success) { | |
print Dumper decode_json($res->content); | |
} | |
else { | |
print $res->content; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment