Search code examples
phpcurlgeomap

fetching the latitude and longitude of a location


I am using curl to fetch the latitude and longitude of a particular location. Even upto today morning I got the response properly. But now I am getting some status is like "OVER_QUERY_LIMIT". If I run the same code from a different file then its working. My code is like:

$last_url = "http://maps.google.com/maps/api/geocode/json?     address=44+Church+st++Parramatta+2150+Australia&sensor=false";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $last_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
/*curl_setopt($ch, CURLOPT_PROXYPORT, 3128);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);*/
$response = curl_exec($ch);
//echo "++++++++++";
echo $response;
curl_close($ch);

$output = json_decode($response);
echo $lat = $output->results[0]->geometry->location->lat;
echo  $long = $output->results[0]->geometry->location->lng;

Please help me.


Solution

  • The problem is obvious, isn't it? You are limited to a certain number of queries per day. There is also a rate limit. You went over one of those limits. If it is working in one script and not the other, you probably hit the rate limit. Wait a few minutes and try again.

    https://developers.google.com/maps/documentation/geocoding/#Limits