繁体   English   中英

Instagram Basic Display API:如何将帖子数量限制在 20 以下?

[英]Instagram Basic Display API: how can I limit the number of posts to less than 20?

使用Instagram Basic Display API ,如何将其获取的帖子数量限制在 20 以下?

PHP一个类中,我为端点定义了以下基本URL

private $_apiBaseUrl = 'https://api.instagram.com/';
private $_graphBaseUrl = 'https://graph.instagram.com/';
public $userId = '';  // defined here, fetched later by getUser();

这两个函数获取帖子:

 // get the posts
        public function getUsersMedia() {
            $params = array(
                'endpoint_url' => $this->_graphBaseUrl . $this->userId . '/media',
                'type' => 'GET',
                'url_params' => array(
                    'fields' => 'id,caption,media_type,media_url',
                )
            );

            $response = $this->_makeApiCall( $params );
            return $response;
        }


   // get more info on a specific post
        public function getMedia( $mediaId ) {
            $params = array(
                'endpoint_url' => $this->_graphBaseUrl . $mediaId,
                'type' => 'GET',
                'url_params' => array(
                    'fields' => 'id,caption,media_type,media_url,permalink,thumbnail_url,timestamp,username'
                )
            );

            $response = $this->_makeApiCall( $params );
            return $response;
        }

这篇文章中,我找到了这个端点:

https://graph.instagram.com/{user-id}/media?fields={media-fields-you-want-to-return}&access_token={access-token}&limit={number-of-media-you-want-to-return}

但是我将如何使用我的函数来完成这项工作? 我不想使用分页,但只返回例如最后 5-10 个帖子。

limit参数的条目添加到url_params数组:

'url_params' => array(
   'fields' => 'id,caption,media_type,media_url',
   'limit'  => 5,
)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM