API-Instagram
view release on metacpan or search on metacpan
Author: Gabriel Vieira <gabriel.vieira@gmail.com>
Date : 2014-08-19 22:37:32 +0000
Many bug fixes; Better cache management; Starting version 0.008'
Change: 3d4f7c2554f544dfbf1607279d96ad908ec7a483
Author: Gabriel Vieira <gabriel.vieira@gmail.com>
Date : 2014-08-17 11:26:38 +0000
Fixed profile_picture method on API::Instagram::User. Objects
creation returns undef when Instagram returns an error during
request. API::Instagram::User keeps user previous data when attempt
to reload fails. Starting version 0.007.
Change: ee143d09d124ba0f37b4710008b43d79d786ff73
Author: Gabriel Vieira <gabriel.vieira@gmail.com>
Date : 2014-08-17 01:37:20 +0000
Removed use API::Instagram::Direct request
Change: 905fe6e5d9a8c1a161372a85a297e785f11113b0
t/00-instagram.t view on Meta::CPAN
client_id => '123',
client_secret => '456',
redirect_uri => 'http://localhost',
no_cache => 1,
_ua => $ua,
});
isa_ok( $api, 'API::Instagram');
ok $api->get_auth_url;
is $api->get_access_token, undef;
$api->code('789');
is $api->code, 789;
ok $api->get_auth_url;
is $api->user->username, undef;
is ref $api->user(123)->relationship('unfollow'), 'HASH';
my ( $access_token, $me ) = $api->get_access_token;
is $access_token, 123456789;
$api->access_token( $access_token );
is $api->access_token, 123456789;
my $api2 = API::Instagram->instance;
isa_ok( $api2, 'API::Instagram');
t/00-media.t view on Meta::CPAN
# First Object
my $media = $api->media(3);
isa_ok( $media, 'API::Instagram::Media' );
is $media->id, 3;
is $media->type, 'video';
is $media->filter, 'Vesper';
is $media->likes, 1;
is $media->comments, 2;
is $media->users_in_photo, undef;
is $media->caption, undef;
is $media->link, 'http://instagr.am/p/D/';
is ref $media->images, 'HASH';
is ref $media->videos, 'HASH';
is ref $media->last_likes, 'ARRAY';
is ref $media->last_comments,'ARRAY';
is ref $media->get_likes, 'ARRAY';
is ref $media->get_comments, 'ARRAY';
my $user = $media->user;
isa_ok( $user, 'API::Instagram::User' );
t/00-user.t view on Meta::CPAN
is $user->followed_by, 3410;
is $user->media(1), 1320;
is $user->follows(1), 420;
is $user->followed_by(1), 3410;
is ref $user->get_follows, 'ARRAY';
is ref $user->get_followers, 'ARRAY';
is ref $user->recent_medias, 'ARRAY';
is $user->feed, undef;
is $user->liked_media, undef;
is $user->requested_by, undef;
__DATA__
{
"data": {
"id": "1574083",
"username": "snoopdogg",
"full_name": "Snoop Dogg",
"profile_picture": "http://distillery.s3.amazonaws.com/profiles/profile_1574083_75sq_1295469061.jpg",
"bio": "This is my bio",
"website": "http://snoopdogg.com",
t/01-location.t view on Meta::CPAN
);
my $data = join '', <DATA>;
my $json = decode_json $data;
$api->mock('_request', sub { $json });
$api->mock('_get_list', sub { [] });
my $location = $api->location( $json->{data} );
isa_ok( $location, 'API::Instagram::Location' );
is $location->id, undef;
is $location->name, undef;
is ref $location->recent_medias, 'ARRAY';
__DATA__
{
"data": {
"latitude": 37.782,
"longitude": -122.387
}
}
t/01-media.t view on Meta::CPAN
);
my $data = join '', <DATA>;
my $json = decode_json $data;
$api->mock('_request', sub { $json });
$api->mock('_get_list', sub { [] });
my $media = $api->media( $json->{data} );
isa_ok( $media, 'API::Instagram::Media' );
is $media->location, undef;
is ref $media->tags, 'ARRAY';
is $media->tags->[0], undef;
my $uip = $media->users_in_photo;
is ref $uip, 'ARRAY';
my $item = $uip->[0];
is ref $item, 'HASH';
my $item_user = $item->{user};
isa_ok( $item_user, 'API::Instagram::User' );
is $item_user->username, 'kevin';
t/01-search.t view on Meta::CPAN
client_secret => '456',
redirect_uri => 'http://localhost',
})
);
my $data = join '', <DATA>;
my $json = decode_json $data;
$api->mock('_request', sub { $json });
my $search = eval { $api->search('car') };
is $search, undef;
__DATA__
{
"data": [
{
"media_count": 43590,
"name": "snowy"
},
{
"media_count": 3264,
t/02-user.t view on Meta::CPAN
my $data = join '', <DATA>;
my $json = decode_json $data;
$api->mock('_request', sub { $json });
$api->mock('_get_list', sub { [] });
my $user = $api->user( $json->{data} );
isa_ok( $user, 'API::Instagram::User' );
is $user->id, 123;
is $user->profile_picture, 'http://test.com/picture.jpg';
is $user->feed, undef;
is $user->liked_media, undef;
is $user->requested_by, undef;
__DATA__
{
"data": {
"id": "123",
"username": "snoopdogg",
"full_name": "Snoop Dogg",
"profile_pic_url": "http://test.com/picture.jpg",
"bio": "This is my bio",
"website": "http://snoopdogg.com",
t/03-user.t view on Meta::CPAN
);
my $data = join '', <DATA>;
my $json = decode_json $data;
$api->mock('_request', sub { $json });
$api->mock('_get_list', sub { [] });
my $user = $api->user( $json->{data} );
isa_ok( $user, 'API::Instagram::User' );
is $user->profile_picture, undef;
__DATA__
{
"data": {
"id": "1574083",
"username": "snoopdogg",
"full_name": "Snoop Dogg",
"profile_pic_url": null,
"profile_picture": null,
"bio": "This is my bio",
t/04-user.t view on Meta::CPAN
my $json = decode_json $data;
$api->mock('_request', sub { $json });
$api->mock('_post', sub { $json });
my $user = $api->user( 123 );
isa_ok( $user, 'API::Instagram::User' );
is ref $user->relationship, 'HASH';
is $user->relationship->{incoming_status}, 'requested_by';
is ref $user->relationship('block'), 'HASH';
is ref $user->relationship('undef'), 'HASH';
__DATA__
{
"meta": {
"code": 200
},
"data": {
"outgoing_status": "none",
"incoming_status": "requested_by"
}
( run in 4.863 seconds using v1.01-cache-2.11-cpan-d80b1682f3f )