{ "status": 0, "message": "ok", "results": [{ "name": "中国民生银行(安定门支行)", "location": { "lat": 39.971315, "lng": 116.413576 }, "address": "北京市朝阳区安定门外大街1号", "province": "北京市", "city": "北京市", "area": "朝阳区", "street_id": "53cebd509fbca9612a02e14c", "telephone": "(010)58295666", "detail": 1, "uid": "53cebd509fbca9612a02e14c" }, { "name": "北京银行(中轴路支行)", "location": { "lat": 39.957382, "lng": 116.404191 }, "address": "北京市东城区安德路16号(洲际大厦首层)", "province": "北京市", "city": "北京市", "area": "东城区", "street_id": "33ddf832c2d7244952e5c51e", "telephone": "95526", "detail": 1, "uid": "33ddf832c2d7244952e5c51e" }, { "name": "交通银行(北京和平里支行)", "location": { "lat": 39.968787, "lng": 116.410049 }, "address": "北京市朝阳区外馆东街51号", "province": "北京市", "city": "北京市", "area": "朝阳区", "street_id": "e56bf5e3064b7b440782c2ff", "telephone": "(010)64408115", "detail": 1, "uid": "e56bf5e3064b7b440782c2ff" }, { "name": "中国进出口银行(北京分行)", "location": { "lat": 39.934898, "lng": 116.411758 }, "address": "北京市东城区北河沿大街77号", "province": "北京市", "city": "北京市", "area": "东城区", "street_id": "6334ddeb6a99710bfea77863", "telephone": "(010)64099688", "detail": 1, "uid": "6334ddeb6a99710bfea77863" }, { "name": "中国工商银行(北京地坛支行)", "location": { "lat": 39.966786, "lng": 116.413857 }, "address": "安定门外大街9号", "province": "北京市", "city": "北京市", "area": "东城区", "street_id": "50f7d1461f0208c472210bff", "telephone": "(010)84122100", "detail": 1, "uid": "50f7d1461f0208c472210bff" }, { "name": "北京银行(沙滩支行)", "location": { "lat": 39.929203, "lng": 116.412428 }, "address": "北京市东城区北河沿大街95号6层97号一层", "province": "北京市", "city": "北京市", "area": "东城区", "street_id": "9ca676f2a814373a43e19275", "telephone": "(010)65220219", "detail": 1, "uid": "9ca676f2a814373a43e19275" }, { "name": "中国银行(安定门外支行)", "location": { "lat": 39.958051, "lng": 116.413457 }, "address": "北京市东城区安定门外大街191号", "province": "北京市", "city": "北京市", "area": "东城区", "street_id": "f4460918f2b3296ab11e36ff", "telephone": "(010)64400221", "detail": 1, "uid": "f4460918f2b3296ab11e36ff" }, { "name": "中国工商银行(北京和平里支行安德公路储蓄所)", "location": { "lat": 39.958072, "lng": 116.407072 }, "address": "北京市东城区安德路47-5号", "province": "北京市", "city": "北京市", "area": "东城区", "street_id": "cc788fde07292f8a88fc06ff", "telephone": "(010)84124439,(010)84124438", "detail": 1, "uid": "cc788fde07292f8a88fc06ff" }, { "name": "中国工商银行(北京东华门支行)", "location": { "lat": 39.921373, "lng": 116.411402 }, "address": "东华门大街20号", "province": "北京市", "city": "北京市", "area": "东城区", "street_id": "dbf4d6eee23caa546ea3cc87", "telephone": "(010)65125921", "detail": 1, "uid": "dbf4d6eee23caa546ea3cc87" }, { "name": "中国工商银行(北京和平北路东口支行)", "location": { "lat": 39.968629, "lng": 116.410245 }, "address": "北京市朝阳区外馆东街51号凯景铭座一层", "province": "北京市", "city": "北京市", "area": "朝阳区", "telephone": "(010)84123118", "detail": 1, "uid": "4482d48423f9a3b33fe23125" } ] }
<?php /** * Created by PhpStorm. * User: FZS * Time: 2019/9/3 23:10 */ //---------------------------------- // 矩形区域检索 调用类 //---------------------------------- class freeApi{ private $ak; private $apiUrl; public function __construct($ak){ $this->ak = $ak; $this->apiUrl = 'http://api.map.baidu.com/place/v2/search?query=银行&bounds=39.915,116.404,39.975,116.414&output=json&ak='.$this->ak; } /** * 获取结果 * @return array */ public function getResult(){ return $this->freeApiCurl($this->apiUrl); } /** * 请求接口返回内容 * @param string $url [请求的URL地址] * @param string $params [请求的参数] * @param int $ipost [是否采用POST形式] * @return string */ public function freeApiCurl($url,$params=false,$ispost=0){ $ch = curl_init(); curl_setopt( $ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1 ); curl_setopt( $ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1 ); curl_setopt( $ch, CURLOPT_USERAGENT , 'free-api' ); curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT , 60 ); curl_setopt( $ch, CURLOPT_TIMEOUT , 60); curl_setopt( $ch, CURLOPT_RETURNTRANSFER , true ); if( $ispost ) { curl_setopt( $ch , CURLOPT_POST , true ); curl_setopt( $ch , CURLOPT_POSTFIELDS , $params ); curl_setopt( $ch , CURLOPT_URL , $url ); } else { if($params){ curl_setopt( $ch , CURLOPT_URL , $url.'?'.$params ); }else{ curl_setopt( $ch , CURLOPT_URL , $url); } } $response = curl_exec( $ch ); if ($response === FALSE) { return false; } curl_close( $ch ); return $response; } }