gil hamer gil hamer - 20 days ago 5
PHP Question

Display single latest instagram photo on your website

I am looking all over the web and can't believe I can't find an answer to my question.
I would like to display the latest single instagram photo on my website. simple as that.

No gallery, no fancybox, no slideshow etc etc

I found this useful link:
http://www.blueprintinteractive.com/blog/how-instagram-api-fancybox-simplified

it's actually working but it doesn't give an option of how many images you would like to display
and I would like only one latest instagram image.

anyone have an idea?

Thanks

Answer

You can break foreach after showing first image like below:

foreach ($result->data as $post) {
  // Do something with this data.
  break; // for one result only
}

Or add &count=1 at end of url as below

https://api.instagram.com/v1/users/ID-GOES-HERE/media/recent/?access_token=TOKEN-GOES-HERE&count=1