我在这里阅读了一些问答和其他文章,但无法让此脚本显示来自 JSON 返回的相关值(来自此 Google Maps 调用的长且经纬度)。
<?php
// Address for Google to search
$address = 'London,UK';
// Get the map json data from Google Maps using the $address variable
$googleCall = 'http://maps.googleapis.com/maps/api/geocode/json?address=' . $address .'&sensor=false';
$json = file_get_contents($googleCall);
//header("Content-type: application/json");
//echo $json;
echo $json->results->geometry->location->lat;
echo $json->results->geometry->location->lng;
?>
我确信我在那里 99%,只是看不到错误在哪里。