快遞物流查詢接口(阿里雲市場接口),調用示例


//獲取阿里雲市場,快遞物流記錄 https://market.aliyun.com/products/56928004/cmapi022273.html?spm=5176.2020520132.101.26.61f97218v18GBF#sku=yuncode1627300000

//get_express_log(self::$config['web']['aliyun_AppCode']阿里雲市場 AppCode,緩存秒數如 300秒,'快遞公司代碼,如:STO',快遞單號,如:3398499691970);
//self::$config['web']是夢行框架的配置變量
function get_express_log($appcode,$show_express_cache,$type,$code){ $cache_path='./express_cache/'.md5($type.$code).'.express'; $cache_file_time=@filemtime($cache_path)+$show_express_cache*60; if(time()<$cache_file_time){return file_get_contents($cache_path);} $host = "https://kdwlcxf.market.alicloudapi.com"; $path = "/kdwlcx"; $method = "GET"; //$appcode = "a9e85f0ded814bc7a97a9f3ad5ccab01"; $headers = array(); array_push($headers, "Authorization:APPCODE " . $appcode); $querys = "no=".$code."&type=".$type; $bodys = ""; $url = $host . $path . "?" . $querys; $curl = curl_init(); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_FAILONERROR, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HEADER, false); //curl_setopt($curl, CURLOPT_HEADER, true); 如不輸出json, 請打開這行代碼,打印調試頭部狀態碼。 //狀態碼: 200 正常;400 URL無效;401 appCode錯誤; 403 次數用完; 500 API網管錯誤 if (1 == strpos("$".$host, "https://")) { curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); } $out_put = curl_exec($curl); file_put_contents($cache_path,$out_put); return $out_put; }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM