PHP调用百度地图API
程序员文章站
2022-05-30 21:57:54
```php
//百度地理位置接口API
$lat = 39.912108791024;
$lng = 116.48299016095;
$ak = "5slgyqGDENN7Sy7pw29IUvrZ"; //秘钥,需要申请,百度为了防止频繁请求
$locationURL = "http://api... ......
//百度地理位置接口api $lat = 39.912108791024; $lng = 116.48299016095; $ak = "5slgyqgdenn7sy7pw29iuvrz"; //秘钥,需要申请,百度为了防止频繁请求 $locationurl = "http://api.map.baidu.com/geocoder/v2/?callback=renderreverse&location=$lat,$lng&output=json&pois=1&ak=$ak"; $ch = curl_init($locationurl) ; curl_setopt($ch, curlopt_returntransfer, true); // 获取数据返回 curl_setopt($ch, curlopt_binarytransfer, true); // 在启用 curlopt_returntransfer 时候将获取数据返回 $result = curl_exec($ch); echo $result;