You’d probably want to wrap what you’ve done up there into a function and do something like.
for ( $counter = 0; $counter <= 1906; $counter += 20) {
$responseURL = 'https://api.hubapi.com/content/api/v2/blog-posts?hapikey=' . $apiKey . '&archived=false&limit=20&offset=" . $counter;
$response = wp_remote_get($responseURL, $getArgs);
process_API_results($response);
$restcounter++;
if($restcounter == 6) { // works out to 120 posts then stops for 2 mins to prevent Hubspot stopping sync
sleep(120);
$restcounter = 0;
}
}
If you echo
out those URL requests you get
https://api.hubapi.com/content/api/v2/blog-posts?hapikey=&archived=false&limit=20&offset=0
https://api.hubapi.com/content/api/v2/blog-posts?hapikey=&archived=false&limit=20&offset=20
https://api.hubapi.com/content/api/v2/blog-posts?hapikey=&archived=false&limit=20&offset=40
https://api.hubapi.com/content/api/v2/blog-posts?hapikey=&archived=false&limit=20&offset=60
https://api.hubapi.com/content/api/v2/blog-posts?hapikey=&archived=false&limit=20&offset=80
…
etc