Complete php code example of the mobile Unicom base station interface for aggregating data-PHP source code

Source: Internet
Author: User
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 ;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.