PHP Instagram的API - 如何获得MIN_TAG_ID和MAX_TAG_ID [英] PHP Instagram API - How to get MIN_TAG_ID and MAX_TAG_ID

查看:694
本文介绍了PHP Instagram的API - 如何获得MIN_TAG_ID和MAX_TAG_ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我周围的Instagrams API努力让所有图像与特定的标签。

Guys I'm working around the Instagrams API to get all images with a specific tag.

下面是我的code:

<?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>';
    }

有了这个code我得到标签图像的20 瑞典

我需要知道我怎么能获得 min_tag_id max_tag_id 这个标签,所以我可以做什么像分页。

I need to know how I can get the min_tag_id and max_tag_id for this tag so I can make a something like pagination.

所以,你能不能给我任何意见,我怎么能得到过去后/图像的ID显示?

So can you give me any advice how can I get the ID of the last post/image displayed ?

在此先感谢!

推荐答案

的Instagram的API返回的next_url和next_max_id节点分页键。修改您的code,这样,如果 $结果['分页'] ['next_url']!='',继续循环。

Instagram's API returns a "pagination" key with the "next_url" and "next_max_id" nodes. Modify your code so that if $result['pagination']['next_url'] != '', the loop continues.

下面的文档: https://instagram.com/developer/endpoints/

这篇关于PHP Instagram的API - 如何获得MIN_TAG_ID和MAX_TAG_ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆