gpt4 book ai didi

PHP Instagram API - 如何获取 MIN_TAG_ID 和 MAX_TAG_ID

转载 作者:搜寻专家 更新时间:2023-10-31 21:07:52 26 4
gpt4 key购买 nike

伙计们,我正在使用 Instagrams API 获取所有带有特定标签的图像。

这是我的代码:

<?PHP
function callInstagram($url)
{
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => 2
));

$result = curl_exec($ch);
curl_close($ch);
return $result;
}

$tag = 'sweden';
$client_id = "XXXX";
$url = 'https://api.instagram.com/v1/tags/'.$tag.'/media/recent?client_id='.$client_id;

$inst_stream = callInstagram($url);
$results = json_decode($inst_stream, true);

//Now parse through the $results array to display your results...
foreach($results['data'] as $item){
$image_link = $item['images']['thumbnail']['url'];
$Profile_name = $item['user']['username'];
echo '<div style="display:block;float:left;">'.$Profile_name.' <br> <img src="'.$image_link.'" /></div>';
}

通过这段代码,我得到了 20 张带有 sweden 标签的图像。

我需要知道如何获取此标记的 min_tag_idmax_tag_id 以便制作分页之类的东西。

那么你能给我一些建议吗?我怎样才能得到最后显示的帖子/图像的 ID?

提前致谢!

最佳答案

来自 instagram 文档:

PAGINATION

Sometimes you just can't get enough. For this reason, we've provided a convenient way to access more data in any request for sequential data. Simply call the url in the next_url parameter and we'll respond with the next set of data.

{
...
"pagination": {
"next_url": "https://api.instagram.com/v1/tags/puppy/media/recent?access_token=fb2e77d.47a0479900504cb3ab4a1f626d174d2d&max_id=13872296",
"next_max_id": "13872296"
}
}
On views where pagination is present, we also support the "count" parameter. Simply set this to the number of items you'd like to receive. Note that the default values should be fine for most applications - but if you decide to increase this number there is a maximum value defined on each endpoint.

https://instagram.com/developer/endpoints/

关于PHP Instagram API - 如何获取 MIN_TAG_ID 和 MAX_TAG_ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29264434/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com