我正在使用下面的代码,在我的网站上显示我的Instagram帐户的一些照片。它只是在div中获取我帐户的所有图像。有没有办法将提取的数据限制在10张图像左右?
无法弄清楚如何做到这一点......
感谢您的帮助!
<div id="instagramfeed">
<?php
// Supply a user id and an access token
$userid = "123xy";
$accessToken = "123xy ";
// Gets our data
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;
}
// Pulls and parses data.
$result = fetchData("https://api.instagram.com/v1/users/{$userid}/media/recent/?access_token={$accessToken}");
$result = json_decode($result);
?>
<?php foreach ($result->data as $post): ?>
<!-- Renders images. @Options (thumbnail,low_resoulution, high_resolution) -->
<a class="group" rel="group1" href="<?= $post->images->standard_resolution->url ?>"><img src="<?= $post->images->thumbnail->url ?>"></a>
<?php endforeach ?> <br><br><br><br>
</div>
答案 0 :(得分:0)
您可以使用count参数。
https://api.instagram.com/v1/users/{$userid}/media/recent/?access_token={$accessToken}&count=10
答案 1 :(得分:0)
这是Instagram Developer Console中的一个问题。 max_id和min_id在那里不起作用。
答案 2 :(得分:0)
对于任何有兴趣的人 - 我找到了解决这个问题的方法:
它不适用于:{$accessToken}&count=10
但它适用于:
?access_token=123456789101112131415123123111&count=10