I'm using Google maps to plot coords. I have a switch construct to delay and resend requests if Google replies with a status of OVER_QUERY_LIMIT.
Coded as-is, with setGeocode calling itself, I'm worried about triggering an infinite loop.
Is there a way to kill the first process after setGeocode makes the secondary call to itself?
Code:public function setGeocode() { $xml = simplexml_load_file($this->request_url) or die("url not loading"); $status = $xml->status; if ($status == 'OK') { $lat = $xml->result->geometry->location->lat; $lng = $xml->result->geometry->location->lng; } elseif($status == 'ZERO_RESULTS') { echo 'No results retured'; } elseif($status == 'OVER_QUERY_LIMIT') { echo 'Over query limit'; usleep(50000);//if we hit query limit take a 5 sec timout then run http request again $this->setGedocode(); } elseif($status == 'REQUEST_DENIED') { echo 'Request denied'; return; } elseif($status == 'INVALID_REQUEST') { echo 'Not enough enough provided'; return; } $this->lat = $lat; $this->lng = $lng; usleep(10000); }



Reply With Quote

Bookmarks