Ibrahim19
Ibrahim19

Reputation: 123

Instagram API - User photos

Does anyone know can I get photos from Instagram user without using access token. It doesn't make sense that I see photos on http://instagram.com/{user} but can not get them using Instagram API.

Upvotes: 8

Views: 17242

Answers (5)

Jydipsinh Parmar
Jydipsinh Parmar

Reputation: 502

Here is a way to get the image from your Instagram account:

$clientId = 'Added-your-client_id';

$set_scope_your_app = "https://www.instagram.com/oauth/authorize/?client_id=$clientId&redirect_uri=Added-your-redirect_uri&response_type=code&scope=public_content";

$get_access_token = "https://instagram.com/oauth/authorize/?client_id=$clientId&redirect_uri=Added-your-redirect_uri&response_type=token";

$url="https://api.instagram.com/v1/users/self/media/recent/?access_token=$get_access_token";
$json = file_get_contents($url);
$data = json_decode($json);

$images = array();
foreach ($data->data as $user_data) {
    $images[] = (array) $user_data->images;
}

$standard = array_map(function($item) {
    return $item['standard_resolution']->url;
}, $images);

echo "<pre>";
    print_r($standard);    
echo "<pre>";
print_r($standard);

I have give Referece to Get User Media or Image in Your Instagram Example

Upvotes: 0

to get the photos You don't need to use the access_token. just call:

https://api.instagram.com/v1/users/{user-id}/media/recent?callback=&client_id={client_id}

you can create your client_id here:

https://instagram.com/developer/clients/manage/

Upvotes: 2

Apoorv
Apoorv

Reputation: 1389

There are 2 ways to get data

1) client side - you need to give client_id

2) server side - you need to give access_token

https://api.instagram.com/v1/users/#{instagram_id}/media/recent/?access_token=#{@token}"

this will give you the recent uploaded photo of that user whose instagram_id is given...

Upvotes: 0

dayuloli
dayuloli

Reputation: 17021

You don't need to use the access_token at all. Just register your application with Instagram, get the client_id and use that to query.

To quote the documentation:

Note that in many situations, you may not need to authenticate users at all. For instance, you may request popular photos without authenticating (i.e. you do not need to provide an access_token; just use your client ID with your request). We only require authentication in cases where your application is making requests on behalf of a user (commenting, liking, browsing a user’s feed, etc.).

Upvotes: 1

Ryan Epp
Ryan Epp

Reputation: 951

No I don't believe this is possible using their api.

From instagram's documentation: (http://instagram.com/developer/authentication/)

Authenticated requests require an access_token. ... We only require authentication in cases where your application is making requests on behalf of a user (commenting, liking, browsing a user’s feed, etc.).

You might be able to work out some kind of hack. Here's a php implementation using followgram.me http://www.barattalo.it/2011/08/18/how-to-use-instagr-am-photos/

Upvotes: 1

Related Questions