API-Instagram

 view release on metacpan or  search on metacpan

lib/API/Instagram.pm  view on Meta::CPAN

has redirect_uri      => ( is => 'ro', required => 1 );
has scope             => ( is => 'ro', default => sub { 'basic' } );
has response_type     => ( is => 'ro', default => sub { 'code'  } );
has grant_type        => ( is => 'ro', default => sub { 'authorization_code' } );
has code              => ( is => 'rw', isa => sub { confess "Code not provided"        unless $_[0] } );
has access_token      => ( is => 'rw', isa => sub { confess "No access token provided" unless $_[0] } );
has no_cache          => ( is => 'rw', default => sub { 0 } );

has _ua               => ( is => 'ro', default => sub { Furl->new() } );
has _obj_cache        => ( is => 'ro', default => sub { { User => {}, Media => {}, Location => {}, Tag => {}, 'Media::Comment' => {} } } );
has _endpoint_url     => ( is => 'ro', default => sub { 'https://api.instagram.com/v1'                 } );
has _authorize_url    => ( is => 'ro', default => sub { 'https://api.instagram.com/oauth/authorize'    } );
has _access_token_url => ( is => 'ro', default => sub { 'https://api.instagram.com/oauth/access_token' } );

has _debug => ( is => 'rw', lazy => 1 );

my $instance;
sub BUILD { $instance = shift }

sub instance { $instance //= shift->new(@_) }

lib/API/Instagram.pm  view on Meta::CPAN

		}
	}

	# If URL is not prepared, prepares it
	unless ( $opts->{prepared_url} ){

		$url =~ s|^/||;
		$params->{access_token} = $self->access_token;

		# Prepares the URL
		my $uri = URI->new( $self->_endpoint_url );
		$uri->path_segments( $uri->path_segments, split '/', $url );
		$uri->query_form($params);
		$url = $uri->as_string;
	}

	# For debugging purposes
	print "Requesting: $url$/" if $self->_debug;

	# Treats response content
	my $res = decode_json $self->_ua->$method( $url, [], $params )->decoded_content;

lib/API/Instagram/Location.pm  view on Meta::CPAN


	for my $media ( @{ $location->recent_medias( count => 5) } ) {

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

	}

=head1 DESCRIPTION

See L<http://instagr.am/developer/endpoints/locations/>.

=head1 ATTRIBUTES

=head2 id

Returns the location id.

=head2 name

Returns the name of the location.

lib/API/Instagram/Media.pm  view on Meta::CPAN

	my $media = $instagram->media(3);

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

	my $location = $media->location;
	printf "Media Location: %s (%f,%f)", $location->name, $location->latitude, $location->longitude;

=head1 DESCRIPTION

See L<http://instagr.am/developer/endpoints/media/>.

=head1 ATTRIBUTES

=head2 id

Returns media id.

=head2 type

Returns media type.

lib/API/Instagram/Media.pm  view on Meta::CPAN

Returns a list of L<API::Instagram::Media::Comment> objects of the media.

Accepts C<count>.

=head2 comment

	$media->comment("Nice pic!");

Creates a comment on the media.

Note: This endpoint is restrict, check  L<https://help.instagram.com/contact/185819881608116> for more information.

=head1 AUTHOR

Gabriel Vieira <gabriel.vieira@gmail.com>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by Gabriel Vieira.

This is free software; you can redistribute it and/or modify it under

lib/API/Instagram/Media/Comment.pm  view on Meta::CPAN


version 0.013

=head1 SYNOPSIS

	print $comment->text . "\n-\n";
	print "By %s, at year %d\n", $comment->from->full_name, $comment->created_time->year;

=head1 DESCRIPTION

See L<http://instagr.am/developer/endpoints/comments/>.

=head1 ATTRIBUTES

=head2 id

Returns comment id.

=head2 from

Returns commenter L<API::Instagram::User> object.

lib/API/Instagram/Search.pm  view on Meta::CPAN

Where B<type> can be: C<user>, C<media>, C<tag> or C<location>.

B<user> parameters:

	my $search = $instagram->search('user');
	$search->find(
		q     => 'larry', # A query string
		count => 5,       # Number of users to return
	);

See L<http://instagram.com/developer/endpoints/users/#get_users_search>.

B<media> parameters:

	my $search = $instagram->search('media');
	$search->find(
		lat => 48.858844, # Latitude of the center search coordinate. If used, lng is required.
		lng => 2.294351, # Longitude of the center search coordinate. If used, lat is required.
		min_timestamp => 1408720000, # A unix timestamp. All media returned will be taken later than this timestamp.
		max_timestamp => 1408723333, # A unix timestamp. All media returned will be taken earlier than this timestamp.
		distance => 500, # Default is 1km (distance=1000), max distance is 5km.
	);

See L<http://instagram.com/developer/endpoints/media/#get_media_search>.

B<tag> parameters:

	my $search = $instagram->search('tag');
	$search->find(
		q => 'perl', # A valid tag name without a leading #.
	);

See L<http://instagram.com/developer/endpoints/tags/#get_tags_search>.

B<location> parameters:

	my $search = $instagram->search('location');
	$search->find(
		distance => 2000, # Default is 1000m (distance=1000), max distance is 5000.
		lat => 48.858844, # Latitude of the center search coordinate. If used, lng is required.
		lng => 2.294351, # Longitude of the center search coordinate. If used, lat is required.
		facebook_places_id => 123, # Returns a location mapped off of a Facebook places id. If used, a Foursquare id and lat, lng are not required.
		foursquare_id => 456, # Returns a location mapped off of a foursquare v1 api location id. If used, you are not required to use lat and lng. Note that this method is deprecated; you should use the new foursquare IDs with V2 of their API.
		foursquare_v2_id => 789, # Returns a location mapped off of a foursquare v2 api location id. If used, you are not required to use lat and lng.
	);

See L<http://instagram.com/developer/endpoints/locations/#get_locations_search>.

=head1 AUTHOR

Gabriel Vieira <gabriel.vieira@gmail.com>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by Gabriel Vieira.

This is free software; you can redistribute it and/or modify it under

lib/API/Instagram/Tag.pm  view on Meta::CPAN


	for my $media ( @{ $tag->recent_medias( count => 5) } ) {

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

	}

=head1 DESCRIPTION

See L<http://instagr.am/developer/endpoints/tags/>.

=head1 ATTRIBUTES

=head2 name

Returns the Tag name.

=head2 media_count

Returns the total media tagged with it.

lib/API/Instagram/User.pm  view on Meta::CPAN

=head1 SYNOPSIS

	my $me    = $instagram->user;
	my $other = $instagra->user(12345);

	printf "My username is %s and I follow %d other users.\n", $me->username, $me->follows;
	printf "The other user full name is %s", $other->full_name;

=head1 DESCRIPTION

See L<http://instagr.am/developer/endpoints/users/> and L<http://instagram.com/developer/endpoints/relationships/>.

=head1 ATTRIBUTES

=head2 id

Returns user id.

=head2 username

Returns user username.



( run in 0.686 second using v1.01-cache-2.11-cpan-63c85eba8c4 )