HERE API从不运行批处理作业,始终返回已接受状态

时间:2017-09-07 20:30:39

标签: php curl here-api

出于某种原因,我的申请今天早上停止了工作。提交作业后,在提出作业请求时,它只会返回accepted

这是我用来创建和运行作业的代码:

$url = "https://batch.geocoder.api.here.com/6.2/jobs?action=run&app_code=".$app_code."&app_id=".$app_id."&mailto=stackoverflow@example.com&outcols=latitude,longitude,locationLabel&outputcombined=true&indelim=|&outdelim=|&language=hu-HU&header=true";
    if($cURLHandler) {
        curl_setopt($cURLHandler, CURLOPT_HTTPHEADER, array('Content-Type: text/plain'));
        curl_setopt($cURLHandler, CURLOPT_BINARYTRANSFER, true);
        curl_setopt($cURLHandler, CURLOPT_POST, true);
        curl_setopt($cURLHandler, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($cURLHandler, CURLOPT_POSTFIELDS, file_get_contents($userFolderURL."/batchjob.txt"));
        curl_setopt($cURLHandler, CURLOPT_URL, $url);

        $cURLResults = curl_exec($cURLHandler);

        curl_close($cURLHandler);
    }

这是一个示例batchjob.txt的内容:

recId|searchText|country
1|"2120 Dunakeszi Barátság útja 18"|HUN
2|"2120 Dunakeszi Barátság útja 18"|HUN
3|"2120 Dunakeszi Baràtsàg útja 12"|HUN
4|"2120 Dunakeszi Barátság utja 49"|HUN
5|"2120 Dunakeszi Barátság útja 3"|HUN
6|"2120 Dunakeszi Barátság útja.30"|HUN
7|"2120 Dunakeszi Bátorkeszi utca 7."|HUN
8|"2120 Dunakeszi bercsényi u 27"|HUN
9|"2120 Dunakeszi Déli utca 12."|HUN

创建并运行作业后,我每隔10秒检查一次状态,并发出以下cURL请求:

$url = "https://batch.geocoder.api.here.com/6.2/jobs/".$requestID."?action=status&app_code=".$app_code."&app_id=".$app_id;

$ch = curl_init();
if($ch) {
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/plain'));
    curl_setopt($ch, CURLOPT_HTTPGET, true);
    curl_setopt($ch, CURLOPT_URL, $url);
    $result = curl_exec($ch);
    curl_close($ch);
}

但它总是返回以下xml:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><ns2:SearchBatch xmlns:ns2="http://www.navteq.com/lbsp/Search-Batch/1"><Response><MetaInfo><RequestId>REQUESTID ommited</RequestId></MetaInfo><Status>accepted</Status><TotalCount>0</TotalCount><ValidCount>0</ValidCount><InvalidCount>0</InvalidCount><ProcessedCount>0</ProcessedCount><PendingCount>0</PendingCount><SuccessCount>0</SuccessCount><ErrorCount>0</ErrorCount></Response></ns2:SearchBatch>

我仔细检查过,我的应用代码&amp; app id都是有效的,所以我真的不明白为什么会发生这种情况。

根据official docs,我的第一个cURL请求应该创建&amp;开始工作,但由于某种原因,它似乎从来没有?这可能是什么问题?

1 个答案:

答案 0 :(得分:2)

状态“已接受”表示您的作业已排队等待插槽执行。我们HERE正在监控队列,以确保根据需要调整容量。

所以我猜你的应用程序还可以,瓶颈可能就在我们这边。