Instagram基本显示API分页 [英] Instagram Basic Display API Pagination

查看:138
本文介绍了Instagram基本显示API分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论如何,对于使用Instagram Basic Display API获得的媒体结果,是否可以使用分页?我已经阅读了以下文档,但是它们没有使用分页的任何示例:

Is there anyway to use paging for the media results obtained using the Instagram Basic Display API? I've read the following documentations but they don't have any examples for using pagination:

  • https://developers.facebook.com/docs/instagram-basic-display-api/reference/media/children
  • https://developers.facebook.com/docs/graph-api/using-graph-api#paging

我想限制响应中返回的媒体,例如媒体1-15进行第一个通话,然后获取下一组,例如在下次通话中16-30.

I would like to limit the media returned in the response e.g. media 1-15 for the first call, then get the next set e.g. 16-30 in the next call.

TIA

推荐答案

通过试用本文档中的分页参数来找到答案:

Found an answer by playing around with the pagination parameters from this documentation: https://developers.facebook.com/docs/graph-api/using-graph-api#paging

当前,默认情况下,基本显示API返回最近的20种媒体.如果要返回的值大于或小于此值,请使用以下网址:

Currently, the Basic Display API returns the most recent 20 media by default. If you want to return more or less than this, use the following url:

https://graph.instagram.com/ { user-id }/media?fields = {您要返回的媒体字段}& access_token = { access-token }& limit = {您想要返回的媒体数量}

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}

要进行分页,需要有一个下一个"端点才能调用.要尝试此操作,请将您的首次通话限制为少于您拥有的媒体数量.您应该获得3个分页端点:

To do pagination, you need to have a "next" endpoint to call. To try this out, limit your first call to less than the number of media that you have. You should get 3 endpoints for pagination:

    "paging": {
              "cursors": {
                       "before": "abc",
                       "after": "def"
               },
              "next": "ghi"
    }

现在将您的下一个端点添加到上面的原始网址中: https://graph.instagram.com/ { user-id }/media?fields = {您要返回的media-fields }& access_token = {< access-token }& limit = { number-要返回的媒体数量}& next = {next-endpoint}

Now add your next endpoint to the original url above: 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}&next={next-endpoint}

这篇关于Instagram基本显示API分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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