I have this part of code used to check if a file is ready to download from Ebay Large Merchant Service
$retry = 0;
do {
if ($retry > 0){sleep(5);}
$response = $session->sendBulkDataExchangeRequest('getJobStatus',$getJobStatusRequestXml);
$xml = simplexml_load_string($response);
if(!empty($xml) && 'Success' == (string)$xml->ack)
{
$jobStatus = (string)$xml->jobProfile->jobStatus;
$completionTime = (string)$xml->jobProfile->completionTime;
$percentComplete = (string)$xml->jobProfile->percentComplete;
$fileReferenceId = (string)$xml->jobProfile->fileReferenceId;
$taskReferenceId = (string)$xml->jobProfile->jobId;
}
$retry++;
} while ($jobStatus == 'Completed' || $retry >=10);
... Others functions to download file...
sendBulkDataExchangeRequest do and API call to check jobStatus.
I need to repeat this call untill jobStatus is Completed or (to skip infinite loop) if retry is => 10 but it doesnt work and try to download the file (next function after do-while) also if jobStatus is InProcess or Scheduled.
Where I'm wrong?
Your while condition is the wrong way round - this will continue 'while' the status is completed or retry >= 10.
You probably want
while ($jobStatus != 'Completed' && $retry <10);
which says repeat while the job isn't completed and the retry count is less than 10.