I've got this working to pull recent Instagram posts into Wordpress, however the "recent" photos that are displayed aren't actually my most recent Instagram posts. When I refresh, the Instagram posts that are pulled in also change. I can only find a max/min time within the API docs. Is there any way to just get the last 3 Instagram posts made?
<?php
$json = file_get_contents('https://api.instagram.com/v1/users/user-id/media/recent/?access_token=key-number');
$a_json = json_decode($json, true);
foreach( $a_json['data'] as $key => $value) {
$a_images[$value['id']]['link'] = $value['link'];
$a_images[$value['id']]['url'] = $value['images']['standard_resolution']['url'];
$a_images[$value['id']]['caption'] = $value['caption']['text'];
}
shuffle($a_images);
echo '<ul>';
$i = 0;
foreach($a_images as $image) {
if ($i < 3) {
echo '<li class="large-4 columns">
<div class="front">
<a href="'.$image[link].'" target="_blank">
<img src="'.$image[url].'"/>
</a>
</div>
<div class="back">
<p>'.$image[caption].'</p>
</div>
</li>';
$i++;
}
}
echo '</ul>';