Php Do-虽然不骑自行车

时间:2018-01-25 15:17:38

标签: php ebay-api

我有这部分代码用于检查文件是否已准备好从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);

...其他功能下载文件...

sendBulkDataExchangeRequest do和API调用以检查jobStatus。

我需要重复这个调用,直到jobStatus完成或(跳过无限循环)如果重试是=> 10但它不起作用并尝试下载文件(do-while后的下一个函数),如果jobStatus是InProcess或Scheduled。

我哪里错了?

1 个答案:

答案 0 :(得分:3)

你的状态是错误的方式 - 这将继续'在'状态完成或重试> = 10。

你可能想要

while ($jobStatus != 'Completed' && $retry <10);

表示在作业未完成且重试次数小于10时重复。