这是我正在尝试运行的简单代码,但它没有输出任何数据。有人可以帮忙吗?谢谢!!
<?php
$addr = "Hotels in ottawa canada";
$a = urlencode($addr);
$geocodeURL =
"https://maps.googleapis.com/maps/api/geocode/json?address=$a&sensor=false&key=my key";
$ch = curl_multi_init($geocodeURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_multi_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$geocode = json_decode($result);
$lat = $geocode->results[$i]->geometry->location->lat;
$lng = $geocode->results[$i]->geometry->location->lng;
echo $formatted_address = $geocode->results[$i]->formatted_address;
echo $geo_status = $geocode->status;
echo $location_type = $geocode->results[0]->geometry->location_type;
echo $location_type = $geocode->results[$i]->geometry->premise;
echo $street_address = $geocode->results[$i]->street_address;
?>