win*_*ung 0 php json geolocation
我想通过使用PHP 5来请求Web服务 - Google Geolocation API.我有使用PHP进行XML解析的经验,但是这个使用JSON格式来发出请求.我不知道如何提出要求!我认为接收请求类似于XML解析!
https://developers.google.com/maps/documentation/business/geolocation/
试试这个(结果是json格式):
public function getGeoPosition($address){
$url = "http://maps.google.com/maps/api/geocode/json?sensor=false" .
"&address=" . urlencode($address);
$json = file_get_contents($url);
$data = json_decode($json, TRUE);
if($data['status']=="OK"){
return $data['results'];
}
}
print_r(getGeoPosition('chicago,il'));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12953 次 |
| 最近记录: |