我目前正在使用 Google Geocoding API,并且非常谨慎地使用它。限制是每天 2500 个查询,我最多可能在 20-50 个范围内。然后在过去的一周里每隔一段时间我就会收到一个 OVER_QUERY_LIMIT 错误。我一次只处理 1 个地址,没有循环或任何东西。它只进行一次地理编码并将 lat/lng 发送到数据库,之后它只会被数据库引用。谁能告诉我为什么我会收到这个错误?
$request_url = "http://maps.googleapis.com/maps/api/geocode/xml?address=".$siteAddress."&sensor=true";
直到大约一周前,这在一个多月的测试中都完美无缺。
我有几页做同样的事情,但只是在不同的时间出于不同的目的被引用。这是地理编码的所有代码。
$request_url = "http://maps.googleapis.com/maps/api/geocode/xml?address=".$siteAddress."&sensor=true"; // the request URL you'll send to google to get back your XML feed
$xml = simplexml_load_file($request_url) or die("url not loading");// XML request
$status = $xml->status;// GET the request status as google's api can return several responses
if ($status=="OK") {
//request returned completed time to get lat / lang for storage
$lat = $xml->result->geometry->location->lat;
$long = $xml->result->geometry->location->lng;
echo "latitude:$lat, longitude:$long <br>";
echo "$lat, $long <br>"; //spit out results or you can store them in a DB if you wish
}
if ($status=="ZERO_RESULTS") {
//indicates that the geocode was successful but returned no results. This may occur if the geocode was passed a non-existent address or a latlng in a remote location.
$errorcode = "ZERO RESULTS";
echo "ZERO RESULTS";
}
if ($status=="OVER_QUERY_LIMIT") {
//indicates that you are over your quota of geocode requests against the google api
$errorcode = "Over Query Limit";
echo "Over Query Limit";
}
if ($status=="REQUEST_DENIED") {
//indicates that your request was denied, generally because of lack of a sensor parameter.
$errorcode = "Request Denied";
echo "Request Denied";
}
if ($status=="INVALID_REQUEST") {
//generally indicates that the query (address or latlng) is missing.
$errorcode = "Invalid Request";
echo "Invalid Request";
}