快递鸟即时查询(PHP)

14 篇文章 0 订阅
// 快递鸟即时查询(就是每天可以白嫖500次的接口)
// 快递鸟接口:https://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx
/**
     * fastBird
     * @param string|int $code 物流编码 比如SF 顺丰快递
     * @param string|int $no 物流单号
     * 快递鸟
     */
    public function fastBird($code , $no)
    {
        $requestData = "{" .
            "'CustomerName': ''," .
            "'OrderCode': ''," .
            "'ShipperCode': '{$code}'," .
            "'LogisticCode': '{$no}'," .
            "}";
        $data = array(
            'EBusinessID' => '用户ID',
            'RequestType' => '1002', //免费即时查询接口指令1002/在途监控即时查询接口指令8001/地图版即时查询接口指令8003
            'RequestData' => urlencode($requestData),
            'DataType' => '2',
        );
        $data['DataSign'] = $this->fastEncrypt($requestData, 'appkey');
        $result = $this->fastSendPost('https://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx', $data);
        return json_decode($result);
    }

    /**
     * @param $url
     * @param $data
     * fastSendPost
     * 快递鸟发送请求
     */
    public function fastSendPost($url, $data)
    {
        $postdata = http_build_query($data);
        $options = array(
            'http' => array(
                'method' => 'POST',
                'header' => 'Content-type:application/x-www-form-urlencoded',
                'content' => $postdata,
                'timeout' => 15 * 60 // 超时时间(单位:s)
            )
        );
        $context = stream_context_create($options);
        $result = file_get_contents($url, false, $context);
        return $result;
    }

    /**
     * @param $data
     * @param $ApiKey
     * fastEncrypt
     * 快递鸟加密
     */
    public function fastEncrypt($data,$ApiKey)
    {
        return urlencode(base64_encode(md5($data . $ApiKey)));
    }
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值