Skip to content

Instantly share code, notes, and snippets.

@sugyan
Created December 12, 2011 07:50
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sugyan/1465751 to your computer and use it in GitHub Desktop.
Save sugyan/1465751 to your computer and use it in GitHub Desktop.
Twitter activity API test
#!/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