如何从 InstaSharp 中的关系端点访问 UsersResponse 中的分页

本文关键字:访问 UsersResponse 分页 端点 关系 InstaSharp | 更新日期: 2023-09-27 18:37:08

我有一个InstaSharp.Endpoints.Relationships.Authenticated对象EP_RELATIONSHIPS,我可以调用EP_RELATIONSHIPS.Follows()来获取我正在关注的用户列表。我关注了几百人,但我只得到了50人的结果。

当我使用 API 控制台检查 Instagram API 页面上的 JSON 数据时,我可以看到有一个分页 URL。

其他返回对象(如 InstaSharp.Model.Responses.MediasResponse)具有一个名为 .Pagination 的对象,该对象似乎提供此功能。

这个库不完整吗?为什么Relationships端点响应中没有分页,我如何在不必重写自己的InstaSharp这一部分的情况下完成分页?

如何从 InstaSharp 中的关系端点访问 UsersResponse 中的分页

最新版本的 Instasharp (https://github.com/InstaSharp/InstaSharp) 在类中具有"分页"属性。

Tags.RecentMultiplePages(..) 方法中,还有一个分页实现用于返回库中的多个页面集,将来可以变得更加通用并推广到多个方法。

您可以

创建自己的对象,该对象具有分页 -> next_url | next_cursor。从响应中获取 json 并将其反序列化为您自己的对象。

为了进一步澄清Damian的答案,如果你看看InstaSharp github上的单元测试,你可以看到如何使用分页的例子:

    public async Task Follows_NextCursor()
    {
        //This test will fail if testing with an account with less than one page of follows
        var result = await relationships.Follows();
        result = await relationships.Follows(457273003/*ffujiy*/, result.Pagination.NextCursor);
        Assert.IsTrue(result.Data.Count > 0);
    }