无论如何,是否可以对使用 Instagram Basic Display API 获得的媒体结果使用分页?我已阅读以下文档,但他们没有任何使用分页的示例:
- https://developers.facebook.com/docs/instagram-basic-display-api/reference/media/children https://developers.facebook.com/docs/instagram-basic-display-api/reference/media/children
- https://developers.facebook.com/docs/graph-api/using-graph-api#paging https://developers.facebook.com/docs/graph-api/using-graph-api#paging
我想限制响应中返回的媒体,例如第一次通话使用媒体 1-15,然后获取下一组,例如16-30 下次通话。
TIA
通过使用本文档中的分页参数找到了答案:https://developers.facebook.com/docs/graph-api/using-graph-api#paging https://developers.facebook.com/docs/graph-api/using-graph-api#paging
目前,Basic Display API 默认返回最近的 20 个媒体。如果您想返回更多或更少的内容,请使用以下 url:
https://graph.instagram.com/ https://graph.instagram.com/{user-id}/媒体?字段={您想要返回的媒体字段}访问令牌={访问令牌}&限制={您想要返回的媒体数量}
要进行分页,您需要有一个要调用的“下一个”端点。要尝试此操作,请将您的第一次呼叫限制为少于您拥有的媒体数量。您应该获得 3 个分页端点:
"paging": {
"cursors": {
"before": "abc",
"after": "def"
},
"next": "ghi"
}
现在将您的下一个端点添加到上面的原始 url 中:https://graph.instagram.com/ https://graph.instagram.com/{user-id}/媒体?字段={您想要返回的媒体字段}访问令牌={访问令牌}&限制={您想要返回的媒体数量}&下一个={下一个端点}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)