{ "status": 0, "message": "ok", "results": [{ "name": "招商银行(方庄支行)", "location": { "lat": 39.872037, "lng": 116.431758 }, "address": "方庄芳古园一区29号楼通润商务会馆B区首层", "province": "北京市", "city": "北京市", "area": "丰台区", "street_id": "9ee392b85e031a41bbbd63d3", "telephone": "(010)87676770", "detail": 1, "uid": "9ee392b85e031a41bbbd63d3" }, { "name": "中国工商银行(北京运河迎宾支行)", "location": { "lat": 39.912176, "lng": 116.683371 }, "address": "北京市通州区故城东路56号(西上园一区9、13号)", "province": "北京市", "city": "北京市", "area": "通州区", "street_id": "9f97b1c5bbdfab78b74f54a7", "telephone": "(010)60562203", "detail": 1, "uid": "9f97b1c5bbdfab78b74f54a7" }, { "name": "中国建设银行24小时自助银行(北京龙锦支行)", "location": { "lat": 40.088242, "lng": 116.355979 }, "address": "北京市昌平区回龙观镇龙锦苑六区14号楼1至2层1号", "province": "北京市", "city": "北京市", "area": "昌平区", "street_id": "ecf0962de0844dee45e27401", "detail": 1, "uid": "ecf0962de0844dee45e27401" }, { "name": "中国工商银行离行式自助服务区(北京分行望京支行郁金香花园)", "location": { "lat": 40.012801, "lng": 116.57051 }, "address": "北京市朝阳区东苇路辅路", "province": "北京市", "city": "北京市", "area": "朝阳区", "street_id": "05d05ce756ad4e9cdb2f283c", "detail": 1, "uid": "05d05ce756ad4e9cdb2f283c" }, { "name": "招商银行ATM(朝阳大悦城)", "location": { "lat": 39.930403, "lng": 116.524959 }, "address": "北京市朝阳区朝阳北路101号朝阳大悦城B1", "province": "北京市", "city": "北京市", "area": "朝阳区", "street_id": "e0d6078dbeadc0859ff7794a", "detail": 1, "uid": "e0d6078dbeadc0859ff7794a" }, { "name": "中国建设银行ATM(颐堤港)", "location": { "lat": 39.975347, "lng": 116.497679 }, "address": "北京市朝阳区酒仙桥路18号颐堤港M", "province": "北京市", "city": "北京市", "area": "朝阳区", "street_id": "5343b9d1a8dc278b32870a71", "detail": 1, "uid": "5343b9d1a8dc278b32870a71" }, { "name": "中国工商银行附行式自助银行(北京分行通州支行永顺潞苑支行)", "location": { "lat": 39.936135, "lng": 116.686147 }, "address": "北京市通州区永顺镇潞苑南里3号院4号楼一层", "province": "北京市", "city": "北京市", "area": "通州区", "street_id": "ffd9bf26ac9c95db4e2fdf17", "detail": 1, "uid": "ffd9bf26ac9c95db4e2fdf17" }, { "name": "中国工商银行ATM(北京定福庄支行)", "location": { "lat": 39.921399, "lng": 116.569927 }, "address": "定福庄南里1号", "province": "北京市", "city": "北京市", "area": "朝阳区", "street_id": "be0e843d4890f83efbdc85d8", "detail": 1, "uid": "be0e843d4890f83efbdc85d8" }, { "name": "中国工商银行离行式自助银行(北京分行顺义支行香花畦家园甲1号)", "location": { "lat": 40.115418, "lng": 116.556654 }, "address": "香花畦家园甲1号楼香花畦家园甲1号楼", "province": "北京市", "city": "北京市", "area": "顺义区", "street_id": "acbfe8bd6eb66ee0ca2915cc", "detail": 1, "uid": "acbfe8bd6eb66ee0ca2915cc" }, { "name": "中国工商银行ATM(北京媒体村支行)", "location": { "lat": 40.0393, "lng": 116.419226 }, "address": "北京市朝阳区天乐园1-2", "province": "北京市", "city": "北京市", "area": "朝阳区", "street_id": "4642844a266507d9c9fa5f75", "detail": 1, "uid": "4642844a266507d9c9fa5f75" } ] }
<?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=ATM机&tag=银行®ion=北京&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; } }