[英]Instagram Basic Display API: how can I limit the number of posts to less than 20?
Using the Instagram Basic Display API
, how can I limit the number of posts that it fetches to less than 20?使用Instagram Basic Display API
,如何将其获取的帖子数量限制在 20 以下?
Inside a class in PHP
, I defined the following base URL
for the endpoints:在PHP
一个类中,我为端点定义了以下基本URL
:
private $_apiBaseUrl = 'https://api.instagram.com/';
private $_graphBaseUrl = 'https://graph.instagram.com/';
public $userId = ''; // defined here, fetched later by getUser();
These two functions get the posts:这两个函数获取帖子:
// 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;
}
In this post I found this endpoint:在这篇文章中,我找到了这个端点:
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}
But how would I make this work with my functions?但是我将如何使用我的函数来完成这项工作? I don't want to use pagination, but only return like, say, the last 5-10 posts.我不想使用分页,但只返回例如最后 5-10 个帖子。
Add an entry for the limit
parameter to the url_params
arrays:将limit
参数的条目添加到url_params
数组:
'url_params' => array(
'fields' => 'id,caption,media_type,media_url',
'limit' => 5,
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.