我以前有一个Google地理编码脚本,用于使用数据库中的本地地址提取经度和纬度。Url没有加载地理编码请求的错误
在过去的6个月中,我切换了主机,显然Google已经实施了一个新的前向地理编码器。现在它只是从xml脚本调用中返回url not loading错误。
我试过一切都让我的代码工作。即使来自其他网站的样本编码在我的服务器上也不起作用。我错过了什么?有没有可能阻止此操作正确执行的服务器端设置?
尝试#1:
$request_url = "http://maps.googleapis.com/maps/api/geocode/xml?new_forward_geocoder=true&address=1600+Amphitheatre+Parkway,+Mountain+View,+CA";
echo $request_url;
$xml = simplexml_load_file($request_url) or die("url not loading");
$status = $xml->status;
return $status;
简单的返回地址不加载。我尝试过使用和不使用new_forwad_geocoder。我也尝试过使用和不使用https。
$ request_url字符串如果只是将其复制并粘贴到浏览器中,它将返回正确的结果。
也试过这只是为了看看我能否得到一个文件返回。尝试2:
$request_url = "http://maps.googleapis.com/maps/api/geocode/json?new_forward_geocoder=true&address=1600+Amphitheatre+Parkway,+Mountain+View,+CA";//&sensor=true
echo $request_url."<br>";
$tmp = file_get_contents($request_url);
echo $tmp;
任何想法,这可能是导致连接失败?