NAME

API::Instagram - OO Interface to Instagram REST API

VERSION

version 0.001

SYNOPSIS

use API::Instagram;

my $instagram = API::Instagram->new({
		client_id   	=> $client_id,
		client_secret	=> $client_secret,
		redirect_uri	=> 'http://localhost',
});

# Authenticated user feed
my $my_user = $instagram->user;
my $feed    = $my_user->feed( count => 5 );

for my $media ( @$feed ) {

	printf "Caption: %s\n", $media->caption;
	printf "Posted by %s at %s (%d likes)\n\n", $media->user->username, $media->created_time, $media->likes;

}

DESCRIPTION

This module implements an OO interface to Instagram REST API.

Authentication

Instagram API uses the OAuth2 for authentication, requering a client_id and client_secret. See http://instagr.am/developer/register/ for details.

Authorize

Get the AUTH URL to authenticate.

use API::Instagram;

my $instagram = API::Instagram->new({
		client_id		=> 'xxxxxxxxxx',
		client_secret	=> 'xxxxxxxxxx',
		redirect_uri	=> 'http://localhost',
		scope           => 'basic',
		response_type   => 'code',
		granty_type     => 'authorization_code',
});

my $auth_url = $instagram->get_auth_url;
print $auth_url;

Authenticate

After authorization, Instagram will redirected the user to the url in redirect_uri with a code as an URL query parameter. This code is needed to obtain an acess token.

$instagram->set_code( $code );
my $access_token = $instagram->get_access_token;

Request

With the access token its possible to request Instagram API using the authenticated user credentials.

$instagram->access_token( $access_token );
my $me = $instagram->get_user;
print $me->full_name;

METHODS

new

my $instagram = API::Instagram->new({
		client_id   	=> $client_id,
		client_secret	=> $client_secret,
		redirect_uri	=> 'http://localhost',
		scope           => 'basic',
		response_type   => 'code',
		granty_type     => 'authorization_code',
});

Returns a API::Instagram object.

Set client_id, client_secret and redirect_uri with the ones registered to your application. See http://instagram.com/developer/clients/manage/.

scope is the scope of access. See http://instagram.com/developer/authentication/#scope.

response_code and granty_type do no vary. See http://instagram.com/developer/authentication/.

get_auth_url

Returns a Instagram authorization URL.

my $auth_url = $instagram->get_auth_url;
print $auth_url;

get_access_token

my $access_token = $instagram->get_access_token;

or

my ( $access_token, $auth_user ) = $instagram->get_access_token;

Returns the access token string if the context is looking for a scalar, or an array containing the access token string and the authenticated user API::Instagram::User object if looking a list value.

media

my $media = $instagram->media( $media_id );
say $media->type;

Get information about a media object. Returns a API::Instagram::Media object.

user

my $me = $instagram->user; # Authenticated user
say $me->username;

my $user = $instagram->user( $user_id );
say $user->full_name;

Get information about user. Returns a API::Instagram::User object.

location

my $location = $instagram->location( $location_id );
say $location->name;

Get information about a location. Returns a API::Instagram::Location object.

tag

my $tag = $instagram->tag('perl');
say $tag->media_count;

Get information about a tag. Returns a API::Instagram::Tag object.

BUGS

Please tell me bugs if you find bug.

<gabriel.vieira at gmail.com>

http://github.com/gabrielmad/API-Instagram

SEE ALSO

WebService::Instagram

AUTHOR

Gabriel Vieira <gabriel.vieira at gmail.com>

LICENSE AND COPYRIGHT

Copyright (c) 2014, Gabriel Vieira <gabriel.vieira at gmail.com>. All rights reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.