欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

PHP调用百度地图API

程序员文章站 2023-09-05 19:49:57
```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;