示例#1
0
文件: data.php 项目: vsur/foodemapp
function callAddToken($nextPageToken)
{
    global $pois;
    // echo "<p><b>NP Token: " . $nextPageToken . "</b></p>";
    $gAddSearchURL = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?pagetoken=" . $nextPageToken;
    $gAddSearchURL = addAPIkey($gAddSearchURL);
    // Wait 1 second, because next page token must be valid at google first!
    usleep(1000000);
    $addInfo = json_decode(file_get_contents($gAddSearchURL));
    if ($addInfo->status != "INVALID_REQUEST") {
        foreach ($addInfo->results as $poi) {
            $array = (array) $poi;
            array_push($pois, $poi);
        }
    } else {
        usleep(500000);
        $addInfo = json_decode(file_get_contents($gAddSearchURL));
        foreach ($addInfo->results as $poi) {
            $array = (array) $poi;
            array_push($pois, $poi);
        }
    }
    if (isset($addInfo->next_page_token)) {
        $nextToken = $addInfo->next_page_token;
        unset($GLOBALS['addInfo']);
        callAddToken($nextToken);
    } else {
        echo '<p><span style="color: green">Crawled all pages</span>: No Next Page Token left!</p>';
    }
}
示例#2
0
 public function callAddToken($nextPageToken)
 {
     $gAddSearchURL = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?pagetoken=" . $nextPageToken;
     $gAddSearchURL = addAPIkey($gAddSearchURL);
     // Wait 1 second, because next page token must be valid at google first!
     usleep(1000000);
     $addInfo = json_decode(file_get_contents($gAddSearchURL));
     // Check if request with next_page_token result is OK
     if ($addInfo->status != "INVALID_REQUEST") {
         // if not INVALID -> Save Data
         foreach ($addInfo->results as $poi) {
             array_push($this->pois, $poi);
         }
         echo ControlFunctions::tagIt("h4", "<span style=\"font-family: monospace;\">Zusätzliche Suchergebnisseite <span style=\"color: green;\">gespeichert</span></span>");
         // Check if another next_page_token is set
         if (isset($addInfo->next_page_token)) {
             echo ControlFunctions::tagIt("h4", "<span style=\"font-family: monospace;\"><span style=\"color: orange;\">Weiteren Next Page Token gefunden. Call again callAddToken()</span></span>");
             $anotherNextPageToken = $addInfo->next_page_token;
             // unset($GLOBALS['addInfo']);
             $this->callAddToken($anotherNextPageToken);
         } else {
             echo ControlFunctions::tagIt("h4", "<span style=\"font-family: monospace;\"><span style=\"color: green\">Crawled all pages</span>: No Next Page Token left!</span>");
         }
     } else {
         echo ControlFunctions::tagIt("h4", "<span style=\"font-family: monospace;\"><span style=\"color: red;\">Next Page Token not yet valid!</span> <span style=\"color: orange;\">Start recall callAddToken()</span></span>");
         $this->callAddToken($nextPageToken);
     }
 }
示例#3
0
 public function radarConcatTypesInOne($queryData)
 {
     // String for request
     $this->gSearchURL .= $queryData->{'geometry'}->{'location'}->{'lat'} . "," . $queryData->{'geometry'}->{'location'}->{'lng'} . "&radius=1500" . "&types=" . $queryData->{'types'}[0] . "|" . $queryData->{'types'}[8] . "|" . $queryData->{'types'}[12] . "|" . $queryData->{'types'}[13] . "|" . $queryData->{'types'}[16] . "|";
     $this->gSearchURL = addAPIkey($this->gSearchURL);
     $info = json_decode(file_get_contents($this->gSearchURL));
     foreach ($info->results as $poi) {
         array_push($this->pois, $poi);
     }
     echo ControlFunctions::tagIt("h2", "<span style=\"font-family: monospace;\">radarConcatTypesInOne()</span><br />" . "Radar Anfrage für meherere Types in einer Anfrage: <span style=\"color: blue;\">" . $queryData->{'types'}[0] . ", " . $queryData->{'types'}[8] . ", " . $queryData->{'types'}[12] . ", " . $queryData->{'types'}[13] . ", " . $queryData->{'types'}[16] . ", " . "</span> Query " . $this->gSearchURL);
     echo ControlFunctions::tagIt("h3", "Einträge: <b>" . count($this->pois) . "</b>");
     $fpois = ControlFunctions::checkDuplicatePID($this->pois);
     echo ControlFunctions::tagIt("h3", "Gefilterte Einträge: <b>" . count($fpois) . "</b>");
     ControlFunctions::formatResultArray($fpois);
     ControlFunctions::forDebug($fpois, "Gefilterte Pois");
 }