Php-based telecom base station interface call code example code description: php-based telecom base station interface call code example
Associated Data: Telecom base station
// + ---------------------------------------------------------------------- // ---------------------------- // Example code of the telecom base station call-aggregate data // online interface documentation: http://www.juhe.cn/docs/16//----------------------------------header ('Content-type: text/html; charset = utf-8 '); // Configure Your applied appkey $ appkey = "*********************"; // ************* 1. telecommunications base station positioning ************ $ url =" http://v.juhe.cn/cdma/ "; $ Params = array (" sid "=>" ", // SID system identifier (one for each region)" nid "=> "", // NID network identification code (1-3 in each region) "cellid" => "", // base station number (bid) "hex" => "", // hexadecimal type, 16 or 10. default value: 10 "dtype" => "", // returned data format: json/xml/jsonp "callback" => "", // when jsonp is selected, "key" => $ appkey, // app key) must be passed; $ paramstring = http_build_query ($ params); $ content = juhecurl ($ url, $ paramstring); $ result = json_decode ($ content, true); if ($ result) {if ($ result ['error _ Code'] = '0 ') {print_r ($ result);} els E {echo $ result ['error _ Code']. ":". $ result ['reason '] ;}} else {echo "request failed ";} //************************************** * ***********/***** request interface returned content * @ param string $ url [requested URL] * @ param string $ params [request parameter] * @ param int $ ipost [whether to use the POST form] * @ return string */function juhecurl ($ url, $ params = false, $ ispost = 0) {$ httpInfo = array (); $ ch = curl_init (); curl_setopt ($ ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSIO N_1_1); curl_setopt ($ ch, CURLOPT_USERAGENT, 'juhedata'); curl_setopt ($ ch, hour, 60); curl_setopt ($ ch, CURLOPT_TIMEOUT, 60); curl_setopt ($ ch, optional, true); curl_setopt ($ ch, CURLOPT_FOLLOWLOCATION, true); if ($ ispost) {curl_setopt ($ ch, CURLOPT_POST, true); curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ params); curl_setopt ($ ch, CURLOPT_URL, $ url);} e Lse {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 ;}