在我的一个php应用程序中,我必须从地址中找出该地点的纬度和经度.
我试过这段代码:
$json = file_get_contents("http://maps.google.com/maps/api/geocode/json?address=$address&sensor=false®ion=$region");
$json = json_decode($json);
$lat = $json->{'results'}[0]->{'geometry'}->{'location'}->{'lat'};
$long = $json->{'results'}[0]->{'geometry'}->{'location'}->{'lng'};
Run Code Online (Sandbox Code Playgroud)
但它显示以下错误:
警告:file_get_contents(http://maps.google.com/maps/api/geocode/json?address=technopark,Trivandrun,kerala,India&sensor = false®ion = IND)[function.file-get-contents]:无法打开流:HTTP请求失败!第4行的D:\ Projects\lon.php中的HTTP/1.0 400错误请求
请帮我解决这个问题.