file_get_contents php Google Maps API-不起作用



im使用此代码使用googlemaps api

获取邮政编码的LAT/日志
$geocodeFrom = file_get_contents('https://maps.google.com/maps/api/geocode/json?address=NP265RE&sensor=false');
$outputFrom = json_decode($geocodeFrom);
$latitudeFrom = $outputFrom->results[0]->geometry->location->lat;
$longitudeFrom = $outputFrom->results[0]->geometry->location->lng;
echo $latitudeFrom;
echo $longitudeFrom;

我从Google接收此错误:{" error_message":"您已经超过了此API的每日请求配额。我们建议在Google Developers Console中注册键:https://console.developers.google.com/apis/recertentials?project = _","结果":[],"状态":" over_query_limit"}

我已经创建了一个Google Maps API键

src="http://maps.googleapis.com/maps/api/js?sensor=false&key=XXX"

但这并不能解决我的问题 - 我在做什么错?

谢谢

是的,因为您正在使用2种不同的API:

使用file_get_contents('https://maps.google.com/maps/api/geocode/json?address=NP265RE&sensor=false');,您正在使用地理编码Web服务。

当您在HTML上添加<script src="http://maps.googleapis.com/maps/api/js?sensor=false&key=XXX">时,您正在使用MAPS JavaScript API在页面上渲染地图。

最新更新