{ "status": "1", "data": { "adcode": "320583", "areacode": "0512", "city": "苏州市", "cityadcode": "320500", "code": "1", "country": "我们", "countrycode": "CN", "cross_list": [{ "distance": "149.103", "level": "45000, 45000", "latitude": "31.31557944", "crossid": "021H51F0090093035--021H51F009009851", "name": "联谊路--绿溪路", "width": "8, 12", "weight": "120", "direction": "West", "longitude": "121.0508253" }, { "distance": "257.444", "level": "45000, 45000", "latitude": "31.31554639", "crossid": "021H51F0090094608--021H51F009009612276", "name": "陆家浜北路--教堂路", "width": "8, 8", "weight": "120", "direction": "East", "longitude": "121.0465464" }, { "distance": "272.069", "level": "45000, 45000", "latitude": "31.31330917", "crossid": "021H51F0090093125--021H51F009009851", "name": "陆家浜南路--绿溪路", "width": "8, 12", "weight": "120", "direction": "NorthEast", "longitude": "121.0482211" } ], "desc": "江苏省,苏州市,昆山市", "district": "昆山市", "districtadcode": "320583", "hn": "20号", "message": "Successful.", "poi_list": [{ "parent": "", "address": "陆家浜北路21号", "distance": "149", "latitude": "31.315573", "weight": "0.0", "type": "医疗保健服务;综合医院;综合医院", "typecode": "090100", "f_nona": "", "childtype": "", "name": "昆山市第四人民医院", "tel": "0512-57877735;0512-57671209", "towards_angle": "", "poiid": "B020007Y9K", "entrances": [{ "latitude": "31.314923", "longitude": "121.047078" }], "end_poi_extension": "2", "direction": "West", "longitude": "121.047687" }, { "parent": "", "address": "陆家镇镇北路21号", "distance": "159", "latitude": "31.315498", "weight": "0.0", "type": "医疗保健服务;综合医院;综合医院", "typecode": "090100", "f_nona": "", "childtype": "", "name": "昆山市陆家人民医院", "tel": "0512-57671209;0512-57879719", "towards_angle": "", "poiid": "B020016BMR", "entrances": [{ "latitude": "31.314934", "longitude": "121.047102" }], "end_poi_extension": "2", "direction": "West", "longitude": "121.047582" }, { "parent": "", "address": "菉溪路22号", "distance": "138", "latitude": "31.314546", "weight": "0.0", "type": "政府机构及社会团体;政府机关;乡镇级政府及事业单位", "typecode": "130105", "f_nona": "", "childtype": "", "name": "陆家镇人民政府", "tel": "0512-57671003", "towards_angle": "153.10", "poiid": "B020007YBU", "entrances": [{ "latitude": "31.314413", "longitude": "121.048453" }], "end_poi_extension": "2", "direction": "SouthWest", "longitude": "121.048460" }, { "parent": "", "address": "菉溪路22号", "distance": "139", "latitude": "31.314539", "weight": "0.0", "type": "政府机构及社会团体;政府机关;乡镇级政府及事业单位", "typecode": "130105", "f_nona": "", "childtype": "", "name": "陆家镇人民代表大会", "tel": "", "towards_angle": "153.20", "poiid": "B020007YBT", "end_poi_extension": "2", "direction": "SouthWest", "longitude": "121.048458" }, { "parent": "", "address": "菉溪路22号", "distance": "139", "latitude": "31.314539", "weight": "0.0", "type": "政府机构及社会团体;政府机关;乡镇级政府及事业单位", "typecode": "130105", "f_nona": "", "childtype": "", "name": "中共昆山市陆家镇委员会", "tel": "", "towards_angle": "153.20", "poiid": "B020008HW1", "end_poi_extension": "2", "direction": "SouthWest", "longitude": "121.048458" } ], "pos": "在陆家镇人民政府附近, 在绿溪路旁边, 靠近联谊路--绿溪路路口", "province": "江苏省", "provinceadcode": "320000", "result": "true", "road_list": [{ "distance": "77", "level": "5", "latitude": "31.3151", "name": "绿溪路", "width": "12", "roadid": "021H51F009009851", "direction": "NorthWest", "longitude": "121.05" }, { "distance": "141", "level": "5", "latitude": "31.3163", "name": "教堂路", "width": "8", "roadid": "021H51F009009612276", "direction": "SouthEast", "longitude": "121.048" }, { "distance": "191", "level": "5", "latitude": "31.3158", "name": "联谊路", "width": "8", "roadid": "021H51F0090093035", "direction": "West", "longitude": "121.051" } ], "sea_area": { "name": "", "adcode": "" }, "tel": "0512", "timestamp": "1563614254525", "version": "1.0" } }
<?php /** * Created by PhpStorm. * User: FZS * Time: 2019/7/20 17:50 */ //---------------------------------- // 地点范围查询 调用类 //---------------------------------- class freeApi{ private $apiUrl = 'https://ditu.amap.com/service/regeo?longitude=121.04925573429551&latitude=31.315590522490712'; /** * 获取 地点范围查询 结果 * @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; } }