1
我只是想输出ottawa输入酒店的格式化地址。结果给我所有我需要的数据和不需要的东西。我需要截断这个。有任何想法吗?如何从谷歌api搜索输出格式化地址?
$address = urlencode("Hotels, in Ottawa");
$geocodeURL = "https://maps.googleapis.com/maps/api/place/textsearch/json?query=hotels+in+Ottawa&sensor=false&key=mykey";
$ch = curl_init($geocodeURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$geocode = json_decode($result);
echo $result;
//echo $formatted_address = $geocode->data[0]->formatted_address;
你的问题不清楚。你认为我们看到你的代码?渥太华有哪些酒店? – 2012-07-06 06:05:45
我想最好给这样一个URL:http://maps.googleapis.com/maps/api/geocode/json?address = hotels + in + Ottawa&sensor = false'并描述你到底想要如何过滤结果 – Teneff 2012-07-06 06:09:20
这是一个快速回复。仍然试图提交代码。从这端提交它和thnx编辑xdazz的一些问题。任何帮助,将不胜感激。 – user1505519 2012-07-06 06:11:59