How do I access pagination in UsersResponse from the Relationships endpoint in InstaSharp?

我是研究僧i 提交于 2020-01-23 13:29:28

问题


I have an InstaSharp.Endpoints.Relationships.Authenticated object EP_RELATIONSHIPS, and I can call EP_RELATIONSHIPS.Follows() to get a list of users I'm following. I follow a few hundred people, but I only get a result of 50.

When I check the JSON data on the Instagram API page using the API Console, I can see that there's a pagination URL.

Other return objects such as InstaSharp.Model.Responses.MediasResponse have an object called .Pagination that seem to provide this functionality.

Is this library incomplete? Why is there no pagination in the Relationships endpoint response and how can I accomplish pagination without having to re-write my own version of this part of InstaSharp?


回答1:


The latest version of Instasharp (https://github.com/InstaSharp/InstaSharp) has the 'Pagination' property in the class.

There is also an implementation of the pagination being used to return multiple page sets in the library also in the Tags.RecentMultiplePages(..) method, which could in the future be made more generic and rolled out to multiple methods.




回答2:


You could create your own object that has the pagination -> next_url | next_cursor. Grab the json from the response and Deserialize it into your own object..




回答3:


To further clarify Damian's answer, if you look at the unit tests on the InstaSharp github, you can see an example of how to use Pagination:

    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);
    }


来源:https://stackoverflow.com/questions/19630605/how-do-i-access-pagination-in-usersresponse-from-the-relationships-endpoint-in-i

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!