Php complete code instance for the mobile Unicom base station interface for aggregating data this code is a base station positioning function based on the mobile Unicom base station Query API for aggregating data
// + Response // ---------------------------------- // sample code for calling the base station Query API // -------------------------------------- header ('content-type: text/html; charset = utf-8 '); $ apiurl =' http://v.juhe.cn/cell/get '; // Base station interface url $ mnc = '0'; // mobile base station: 0 Unicom base station: 1 default: 0 $ cell = '123 '; // Large area code $ lac = '000000'; // small area code $ key = '52a0ee009932b35054 ********'; // appkey $ params = "mnc ={$ mnc} & cell ={$ cell} & lac ={$ lac} & key ={$ key }"; $ content = juhecurl ($ apiurl, $ params); if (! $ Content) {echo "network error, request interface failed";} else {$ result = json_decode ($ content, true ); $ error_code = $ result ['error _ Code']; if ($ error_code = 0) {// successfully request data $ data = $ result ['result'] ['data'] [0];/* "MCC": "460", "MNC ": "1", "LNG": "120.721423", // gps coordinate: longitude "LAT": "31.29854", // gps coordinate: Latitude "O_LNG": "120.72577772352 ", // AMAP coordinate: longitude "O_LAT": "31.296529947917", // AMAP coordinate: Latitude "PRECISION": "1101", // base station coverage radius "ADDRESS ": "No. 368, Jinji Lake Avenue, Wuzhong District, Suzhou city, Jiangsu province "// Base station address */print_r ($ data);} else {echo $ result ['reason ']. "(". $ result ['error _ Code']. ")" ;}} function juhecurl ($ url, $ params = false, $ ispost = 0) {$ httpInfo = array (); $ ch = curl_init (); curl_setopt ($ ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_setopt ($ ch, CURLOPT_USERAGENT, 'mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) chrome/41.0.2272.118 Safari/537.36 '); Curl_setopt ($ ch, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt ($ ch, CURLOPT_TIMEOUT, 30); 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) {// echo "cURL Error :". curl_error ($ ch); return false;} $ httpCode = curl_getinfo ($ ch, CURLINFO_HTTP_CODE); $ httpInfo = array_merge ($ httpInfo, curl_getinfo ($ ch )); curl_close ($ ch); return $ response ;}