I'm looking for some helping with using a php instagram feed.
I found this link through my research and it works perfectly but I don't know how to limit the results from instagram's default of 20.
I'd really just like to show 6 images at a time.
I'm not great with php so please forgive my ignorance.
Please see the code below
<?php
function fetchData($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
$result = fetchData("https://api.instagram.com/v1/users/ID-GOES-HERE/media/recent/?access_token=TOKEN-GOES-HERE");
$result = json_decode($result);
foreach ($result->data as $post) {
// Do something with this data.
}
?>
You can specify the number of images to return using the COUNT parameter. Try this:
$result = fetchData("https://api.instagram.com/v1/users/ID-GOES-HERE/media/recent/?access_token=TOKEN-GOES-HERE&count=6");
If you are looking to retrieve a greater number of records and page through them on your side, check out the min_id and max_id for paging.