Show one last instagram photo on your site

I look all over the Internet and cannot believe that I can not find the answer to my question. I would like to show the latest single instagram photo on my website. just like that.

No galleries, no fancybox, slide shows, etc.

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

It really works, but it does not give you the possibility of how many images you would like to display and I would like only one last instagram image.

Does anyone have an idea?

thank

+4
source share
3 answers

break foreach , :

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

&count=1 url,

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

Try the following:

$page_id = 'YOUR ID';
$access_token = 'YOUR ACCESS TOKEN';
$json_object = @file_get_contents('https://api.instagram.com/v1/users/' . $page_id . 
'/media/recent/?access_token=' . $access_token . '&count=1');
$indata = json_decode($json_object);
echo $indata->data[0]->images->low_resolution->url // for low res
echo $indata->data[0]->images->thumbnail->url;      //for thumbnail
echo $indata->data[0]->images->standard_resolution->url; //for standard res
echo $indata->data[0]->caption->text; //for caption

Attaching the entire message may be the solution:

$json_post = @file_get_contents('https://api.instagram.com/oembed/?url=' . $indata->data[0]->link);
$oembed = json_decode($json_post, true);
echo $oembed['html'];

Good luck

0
source

Source: https://habr.com/ru/post/1538561/


All Articles