Geocode无法在我的新主机上使用php


Geocode not working with php on my new host

我在以前的主机上使用了PHP中的谷歌地理编码脚本(仍在工作),但在hostgator中停止了对VPS的工作。

$url="http://maps.googleapis.com/maps/api/geocode/json?address=?Toronto,+ON&sensor=true";
$latlon = @file_get_contents($url);
$latlong =json_decode($latlon, true);

我也试过:

$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL, $url);
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
curl_setopt($curl_handle, CURLOPT_HEADER, 0);
$latlong = curl_exec($curl_handle);
curl_close($curl_handle);

两者都提供

{
  "status": "REQUEST_DENIED",
  "results": [ ]
}

我试过雅虎API,它有效!(但@file_get_contents也不适用于雅虎)。

如有任何帮助,我们将不胜感激。

似乎您每天调用谷歌允许的Web服务的限制已过期。