Google Geocoding API错误消息:“You have exceeded…”当试图获取经纬度时


Google Geocoding API error message: “You have exceeded…” when trying to get latitude and longitude

我知道这意味着我超过了我的每日请求,但问题是,当我每天只做几个请求时,它就会发生,它没有工作过一次。

我只是尝试简单地使用API,所以我没有办法超过我的每日请求(每24小时内有2500个请求)。

也许我错过了什么…

下面是我的代码:——
$loc_array = json_decode( file_get_contents('http://maps.googleapis.com/maps/api/geocode/json?address='.str_replace(" ","+",$address).'&sensor=true') );
if($loc_array->status != 'ZERO_RESULTS'){
    $data['lat1'] = $loc_array->results[0]->geometry->location->lat;
    $data['lon1'] = $loc_array->results[0]->geometry->location->lng;
    $data['status'] = true;
    return $data;
}
else 
{
    $data = array("status"=>false);
    return $data;
}

通过

从API得到JSON响应
{ 
 "error_message" : "You have exceeded your daily request quota for this API.",
 "results" : [],  
 "status" : "OVER_QUERY_LIMIT"
}

请帮助我如何解决它。给我一些建议吧。

当超过每天2500个请求的限制时出现此错误。由于您的请求中没有包含任何API密钥,因此您将无法跟踪您发出的API请求的数量。

所以你应该包括API密钥从你的谷歌开发者API控制台,可以检查你消耗的请求在当天没有。它将给出API使用的所有统计数据。

你可以在这里查看:https://console.developers.google.com/iam-admin/quotas?project=YOUR_PROJECT_NAME

谢谢