//Json方式 查询订单物流轨迹
function getOrderTracesByJson($kgs, $number)
{
$requestData = "{'OrderCode':'','ShipperCode':'$kgs','LogisticCode':'$number'}";
$datas = array(
'EBusinessID' => '****',
'RequestType' => '****',
'RequestData' => urlencode($requestData),
'DataType' => '2',
);
$datas['DataSign'] = $this->encrypt($requestData, 'fdf75944-8e72-4c72-b40f-534b0336b552');
$result = $this->sendPost('http://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx', $datas);
//根据公司业务处理返回的信息......
return $result;
}
//请求Url
function sendPost($url, $datas)
{
$temps = array();
foreach ($datas as $key => $value) {
$temps[] = sprintf('%s=%s', $key, $value);
}
$post_data = implode('&', $temps);
$url_info = parse_url($url);
if (empty($url_info['port'])) {
$url_info['port'] = 80;
}
$httpheader = "POST " . $url_info['path'] . " HTTP/1.0\r\n";
$httpheader .= "Host:" . $url_info['host'] . "\r\n";
$httpheader .= "Content-Type:application/x-www-form-urlencoded\r\n";
$httpheader .= "Content-Length:" . strlen($post_data) . "\r\n";
$httpheader .= "Connection:close\r\n\r\n";
$httpheader .= $post_data;
$fd = fsockopen($url_info['host'], $url_info['port']);
fwrite($fd, $httpheader);
$gets = "";
$headerFlag = true;
while (!feof($fd)) {
if (($header = @fgets($fd)) && ($header == "\r\n" || $header == "\n")) {
break;
}
}
while (!feof($fd)) {
$gets .= fread($fd, 128);
}
fclose($fd);
return $gets;
}
// 电商Sign签名生成
function encrypt($data, $appkey)
{
return urlencode(base64_encode(md5($data . $appkey)));
}
快递鸟查询物流
猜你喜欢
转载自blog.csdn.net/weixin_43784997/article/details/115235138
今日推荐
周排行