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

查看:33
本文介绍了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:

我想限制响应中返回的媒体,例如媒体 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

推荐答案

通过使用以下文档中的分页参数找到了答案:https://developers.facebook.com/docs/graph-api/using-graph-api#paging

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

目前,Basic Display 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={media-fields-you-want-to-return}&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-you-want-to-return}&access_token={access-token}&limit={number-of-media-you-want-to-return}&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天全站免登陆