您好,登錄后才能下訂單哦!
有些接口用CURL調用的時候,要發送header頭信息
如百度的查詢快遞的接口
PHP代碼如下:
$url = "https://sp0.baidu.com/9_Q4sjW91Qh4otqbppnN2DJv/pae/channel/data/asyncqury?appid=4001&com={$type}&nu={$deliveryBn}"; $headers = array( "Host: sp0.baidu.com", "Connection: keep-alive", "Cache-Control: max-age=0", "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,p_w_picpath/webp,*/*;q=0.8", "User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.124 Safari/537.36", "Accept-Encoding: gzip, deflate, sdch", "Accept-Language: zh-CN,zh;q=0.8", "Cookie: BAIDUID=FAFE6A61C5C95A71A482ABC3315F9228:FG=1; BIDUPSID=FAFE6A61C5C95A71A482ABC3315F9228; PSTM=1435563408; BD_UPN=12314653 "); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $output = curl_exec($ch); curl_close($ch); $arr = json_decode($output, true) /** $type是快遞公司的代碼簡稱,如:yuantong,shentong,ems,shunfeng,yunda,zhongtong,tiantian,debang,zhaijisong等 $deliveryBn則是運單號 **/
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。