-1

I need show the photos from instagram with my company hash tag to my website. I'm using the code of below:

<?php 
 function callInstagram($url)
{
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => 2
));

$result = curl_exec($ch);
curl_close($ch);
return $result;
}

$tag = 'hermomy';
$client_id = 'my client id';

$url = 'https://api.instagram.com/v1/tags/'.$tag.'/media/recent?client_id='.$client_id;

$inst_stream = callInstagram($url);
$results = json_decode($inst_stream, true);

//Now parse through the $results array to display your results... 
foreach($results['data'] as $item){
    $image_link = $item['images']['low_resolution']['url'];
    echo '<img src="'.$image_link.'" />';
}
?>

*I'm already replace the "my client id" to my true client id

After it i get the result of only show 13 photos from it, by right it should have 373 photos. You may check http://web.stagram.com/tag/hermomy/ . total is about 373 photos with this hash tag - #hermomy My result page - 103.6.244.109/~hermo/ayeetest.php So,how can i show all those photos?

Jason Kuah
  • 57
  • 1
  • 2
  • 3
  • 1
    A quick check of the docs says that that URL will only give recently tagged photos: http://instagram.com/developer/endpoints/tags/# – Jim Sep 04 '13 at 10:57

2 Answers2

0

Someone else may be better able to answer but this doesn't seem possible looking at the api.

The reason you are only seeing 13 is that the url you are using is only for recent media. See Tag Endpoint.

Jim
  • 22,354
  • 6
  • 52
  • 80
0

Instagram API will not return all photos with a single API call, each call I think returns a maximum of 20 photos. After making the first API call, you have to use the "next_url" in "pagination" of JSON response to make another API call to get the next set of 20 images, for example you may have to implement a "show more" button which will load the next set and so on.

Below is a typical response you get from a instagram API, the making a request to API url at pagination.next_url will return you the next set of photos.

{
    "meta": {
        "code": 200
    },
    "data": {
        ...
    },
    "pagination": {
        "next_url": "...",
        "next_max_id": "13872296"
    }
}
krisrak
  • 12,882
  • 3
  • 32
  • 46