Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to get pagination for adhoc request #51

Closed
sang-d opened this issue Oct 10, 2016 · 1 comment
Closed

how to get pagination for adhoc request #51

sang-d opened this issue Oct 10, 2016 · 1 comment

Comments

@sang-d
Copy link

sang-d commented Oct 10, 2016

Hi team,
Just have a question, how does pagination work for cases like below:

    APIResponse res = new APIRequest<APINode>(context, "", "search", "GET").execute(params);

Please advise.
Thanks,
Sang

@JiamingFB
Copy link
Contributor

Hi @sang-d

You can do something like the following. Basically you can cast the api response into a APINodeList, and then do the pagination.

    APIRequest<Campaign> campaigns_request = new APIRequest<Campaign>(context, "act_" + account.getId(), "/campaigns", "GET", null, Campaign.getParser())
        .requestField("name");
    APINodeList<Campaign> campaigns = (APINodeList<Campaign>)(campaigns_request.execute());
    for (Campaign campaign : campaigns) {
      System.out.println("campaign: " + campaign);
    }
    campaigns = campaigns.nextPage();
    for (Campaign campaign : campaigns) {
        System.out.println("campaign: " + campaign);
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants