当前位置 : 主页 > 网络编程 > PHP >

快递实时查询API.PHP

来源:互联网 收集:自由互联 发布时间:2021-06-28
快递实时查询API.PHP 'LK664578623CN', 'carrier_code'='china-ems'); $res = curl_post($url,json_encode($postData),$header);print_r($res); function curl_post($url, $postData,$header=array(),$cookie_file='',$isheader=0,$proxy='',$debug=0,$
快递实时查询API.PHP
 'LK664578623CN',
    'carrier_code'=>'china-ems'
);
 
$res = curl_post($url,json_encode($postData),$header);
print_r($res);
  
 function curl_post($url, $postData,$header=array(),$cookie_file='',$isheader=0,$proxy='',$debug=0,$autoRedirect=0,$time=89){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    if(!empty($isheader)){
        curl_setopt($ch, CURLOPT_HEADER, $isheader);
    }  
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
    curl_setopt($ch, CURLOPT_TIMEOUT,$time);
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1; rv:44.0) Gecko/20100101 Firefox/44.0');
    if(!empty($header)){
        curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
    }
     
    if(!empty($autoRedirect)){
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    }
    if(!empty($cookie_file)){
        // 读取文件所储存的Cookie信息
        curl_setopt ( $ch, CURLOPT_COOKIEFILE, $cookie_file );
    }
    if(!empty($proxy)){
         curl_setopt($ch, CURLOPT_PROXY, $proxy);
    }
    //curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate');
    if(!empty($debug)){
         curl_setopt($ch,CURLOPT_VERBOSE,1);
         curl_setopt($ch,CURLOPT_FAILONERROR,TRUE);
         print_r(curl_error($ch));
         print_r(curl_getinfo($ch));
    }
    $html = curl_exec($ch);
    curl_close($ch);
    return $html;
}
上一篇:findPwdAction.class.php
下一篇:orderID.php
网友评论