Recent searches


No recent searches

How can I fetch multiple pages of results automatically?



Edited Jul 12, 2023


4

2

2 comments

It seems that CURLOPT_SSL_VERIFYHOST now needs to be set to 2.

If you don't already have php-curl installed, you'll need that package as well.

If you run it and get a zero-length output file, try changing the $end_page to 2. If you ask for a page that doesn't exist it overwrites the file with nothing at all. However it seems to handle things correctly up to then. You get 100 records per page, so for example if you have 650 records, you'll need to set $end_page to 6.
If you're getting organizations, for example, you can use something like this to get the count so you know how many pages to get. The count may not be accurate over 100,000. See https://developer.zendesk.com/rest_api/docs/support/organizations.

curl https://{subdomain}.zendesk.com/api/v2/organizations/count.json \
  -v -u {email_address}:{password}

I know this is just an example and not meant to be robust. This isn't a complaint or request for changes, just adding these comments here in case they help someone like myself in the future. 

0


image avatar

Brett Bowser

Zendesk Community Manager

Thanks for taking the time to share this with everyone Seneca :)

0


Please sign in to leave a comment.