Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php xml谷歌地理编码错误_Php_Xml_Simplexml_Google Geocoder - Fatal编程技术网

php xml谷歌地理编码错误

php xml谷歌地理编码错误,php,xml,simplexml,google-geocoder,Php,Xml,Simplexml,Google Geocoder,如果我理解谷歌的错误超过了查询限制的权利,那是因为太多的ip请求。 但如果我转到浏览器并加载以下链接: 我可以看到xml 那为什么呢 我的代码有问题吗 这是: $the_map = htmlspecialchars($_POST['map'], ENT_QUOTES); error_reporting(0); $map_query = file_get_contents('http://maps.google.com/maps/api/geocode/xml?addr

如果我理解谷歌的错误超过了查询限制的权利,那是因为太多的ip请求。 但如果我转到浏览器并加载以下链接:

我可以看到xml

那为什么呢

我的代码有问题吗

这是:

    $the_map = htmlspecialchars($_POST['map'], ENT_QUOTES);

    error_reporting(0);
    $map_query = file_get_contents('http://maps.google.com/maps/api/geocode/xml?address='.rawurlencode($the_map).'&sensor=false');
    error_reporting(1);

    if ($map_query){
        $geo_code = simplexml_load_string(utf8_encode($map_query));

        if ($geo_code){
            $map_lat = $geo_code->xpath("/GeocodeResponse/result/geometry/location/lat");
            $map_lng = $geo_code->xpath("/GeocodeResponse/result/geometry/location/lng");
            $map_lat = $map_lat[0][0];
            $map_lng = $map_lng[0][0];
        }
    }

使用卷曲代替文件获取内容

$address = "India+Panchkula";
$url = "http://maps.google.com/maps/api/geocode/json?address=$address&sensor=false&region=India";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXYPORT, 3128);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$response = curl_exec($ch);
curl_close($ch);
$response_a = json_decode($response);
echo $lat = $response_a->results[0]->geometry->location->lat;
echo "<br />";
echo $long = $response_a->results[0]->geometry->location->lng;
$address=“印度+潘什库拉”;
$url=”http://maps.google.com/maps/api/geocode/json?address=$address&sensor=false®ion=India”;
$ch=curl_init();
curl_setopt($ch,CURLOPT_URL,$URL);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_PROXYPORT,3128);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,0);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,0);
$response=curl\u exec($ch);
卷曲关闭($ch);
$response\u a=json\u decode($response);
echo$lat=$response\u a->results[0]->geometry->location->lat;
回声“
”; echo$long=$response_a->results[0]->geometry->location->lng;
或查看以下URL


好的。几天后,我对“卷曲”也有同样的问题。我得到这个“超过查询限制”错误。但这毫无意义,我没有那么多的谷歌请求。每天最多10个。那又怎么样。。我怎样才能解决这个问题?