限制Php获取中的Instagram提要
我正在使用下面的代码,在我的网站上显示我的instagram帐户的一些照片。它只获取div中我帐户的所有图像。有没有办法将获取的数据限制为10个左右的图像 我想不出怎么做 谢谢你的帮助限制Php获取中的Instagram提要,php,limit,instagram,fetch,Php,Limit,Instagram,Fetch,我正在使用下面的代码,在我的网站上显示我的instagram帐户的一些照片。它只获取div中我帐户的所有图像。有没有办法将获取的数据限制为10个左右的图像 我想不出怎么做 谢谢你的帮助 <div id="instagramfeed"> <?php // Supply a user id and an access token $userid = "123xy"; $accessToken = "123xy ";
<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>
您可以使用count参数
https://api.instagram.com/v1/users/{$userid}/media/recent/?access_token={$accessToken}&count=10
这是Instagram开发者控制台中的一个问题。max\u id和min\u id在那里不起作用。对于任何感兴趣的人,我找到了解决此问题的方法: 它不适用于:
{$accessToken}&count=10
但它与:
?访问令牌=12345678910112131415123111&count=10
是的,我以前试过。。对不起,我没那么说。当我这样做时,div是完全空的。。我不知道为什么会这样(