I have a curl request on an api with pagination and now I'd like to execute my php script several times so that I don't have to start it manually with a different pagenumber
$endpoint = 'https://xxx.weclapp.com/webapp/api/v1/';
$api_token = 'xxx';
$articlePerPage = 100;
$currentPage = 1;
$amountOfArticles = "different curl get request (approx 1100)"
$amountOfPages = ceil($amountOfArticles / $articlePerPage);
$header = array();
$header[] = 'Content-type: application/json';
$header[] = 'AuthenticationToken:'.$api_token;
curl_setopt($curl, CURLOPT_HTTPHEADER,$header);
curl_setopt($curl, CURLOPT_URL,$endpoint.'article/?page='.$currentPage.'&pageSize='.$articlePerPage);
curl_setopt($curl, CURLOPT_HTTPGET, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$JSON = curl_exec($curl);
$result = json_decode($JSON);
I tried to put it in a while loop
while ($currentPage <= $amountOfPages) : ...; endwhile;
but unfortunately there are to much products respectively it takes to long so my server won't finish all these calls and I get a 504
At the moment I start this script manually 12 times each time with a different $currentPage number. My idea is to let the server finish the script, then restart it with $currentPage++ but I don't have any clue how to do that.
I've read the solution on this topic 9798438 with the bin/bash script but then I can't change my $currentPage variable
Does anyone has any idea how I could manage what I'm trying to do?
Thank you very much, I'd appreciate any help
Alex