{ "status": 0, "message": "ok", "results": [{ "name": "我们银行ATM(西交民巷)", "location": { "lat": 39.908251, "lng": 116.400296 }, "address": "西交民巷甲19号", "province": "北京市", "city": "北京市", "area": "西城区", "street_id": "90f3c114c3f7fceb25d2bb1e", "detail": 1, "uid": "90f3c114c3f7fceb25d2bb1e" }, { "name": "我们银行24小时自助银行服务(东华门大街)", "location": { "lat": 39.921443, "lng": 116.410409 }, "address": "北京市东城区东华门大街54号", "province": "北京市", "city": "北京市", "area": "东城区", "street_id": "d821e9337fec6b2597031941", "detail": 1, "uid": "d821e9337fec6b2597031941" }, { "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.921398, "lng": 116.411576 }, "address": "北京市东城区东华门大街20号", "province": "北京市", "city": "北京市", "area": "东城区", "detail": 1, "uid": "5555f7ca9e9fb0a23f9a5eee" }, { "name": "我们民生银行24小时自助银行(北京正义路支行)", "location": { "lat": 39.910084, "lng": 116.413679 }, "address": "正义路甲3", "province": "北京市", "city": "北京市", "area": "东城区", "street_id": "56f2f6962315f3800aa8d4c9", "detail": 1, "uid": "56f2f6962315f3800aa8d4c9" }, { "name": "我们民生银行(正义路支行)", "location": { "lat": 39.909913, "lng": 116.413661 }, "address": "北京市东城区正义路甲3号", "province": "北京市", "city": "北京市", "area": "东城区", "street_id": "d5101afd619d12c7f423100e", "telephone": "(010)65262045", "detail": 1, "uid": "d5101afd619d12c7f423100e" }, { "name": "北京银行(前门支行)", "location": { "lat": 39.906018, "lng": 116.401304 }, "address": "北京市西城区西大街正阳市场1号楼底商", "province": "北京市", "city": "北京市", "area": "西城区", "street_id": "be2d09340d0b5c0035b06c31", "telephone": "(010)63048577", "detail": 1, "uid": "be2d09340d0b5c0035b06c31" }, { "name": "北京银行文化创客中心", "location": { "lat": 39.906005, "lng": 116.401277 }, "address": "前门西大街正阳市场1号楼北京银行前门支行2层", "province": "北京市", "city": "北京市", "area": "西城区", "detail": 1, "uid": "05b5f25c148d7985b64f543c" }, { "name": "北京银行24小时自助银行(前门支行)", "location": { "lat": 39.905998, "lng": 116.400954 }, "address": "西城区前门西大街正阳市场1号", "province": "北京市", "city": "北京市", "area": "西城区", "street_id": "08f1f1f5a23b39ca88db73e6", "detail": 1, "uid": "08f1f1f5a23b39ca88db73e6" }, { "name": "我们工商银行24小时自助银行(北京正阳门支行)", "location": { "lat": 39.906493, "lng": 116.409279 }, "address": "前门东大街16号", "province": "北京市", "city": "北京市", "area": "东城区", "detail": 1, "uid": "e6c265d1a03a8955d813189e" } ] }
<?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=银行&location=39.915,116.404&radius=2000&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 , 'chuanshuoapi' ); 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; } }