快递100开放快递查询接口

版权声明:该文章来源于CBDLL的博客,转载请备注 https://blog.csdn.net/CB_1213/article/details/86637524

http://www.kuaidi100.com/query?type=快递运营商名&postid=快递单号

type支持的快递公司及参数说明:https://cdn.kuaidi100.com/download/chaxun(20140729).doc

PHP请求查询快递方式

请求地址:

正式环境请求地址:https://poll.kuaidi100.com/poll/query.do

请求类型:

POST

输入参数:
名称 类型 描述描述
customer String 贵司的的公司编号, 请参考邮件《快递100-企业版快递查询接口(API)——授权key及相关工具》
sign String 签名, 用于验证身份, 按param + key + customer 的顺序进行MD5加密(注意加密后字符串一定要转大写), 不需要加上“+”号, 如{“com”: “yuantong”, “num”: “500306190180”, “from”: “广东省深圳市”, “to”: “北京市朝阳区”}xxxxxxxxxxxxyyyyyyyyyyy yyyyyyyyyyyyyyyyyyyyy
param Object 由其他字段拼接
返回结果:
字段名称 字段含义
message 消息体,请忽略
state 快递单当前签收状态,包括0在途中、1已揽收、2疑难、3已签收、4退签、5同城派送中、6退回、7转单等7个状态,其中4-7需要另外开通才有效
status 通讯状态,请忽略
condition 快递单明细状态标记,暂未实现,请忽略
ischeck 是否签收标记,请忽略,明细状态请参考state字段
com 快递公司编码,一律用小写字母
nu 单号
data 最新查询结果,数组,包含多项,全量,倒序(即时间最新的在最前),每项都是对象,对象包含字段请展开
返回示例:

JSON格式

  {
        "message":"ok",
        "state":"0",
        "status":"200",
        "condition":"F00",
        "ischeck":"0",
        "com":"yuantong",
        "nu":"V030344422",
        "data":[
        {
          "context":"上海分拨中心/装件入车扫描 ",
          "time":"2012-08-28 16:33:19",
          "ftime":"2012-08-28 16:33:19",
        },
        {
          "context":"上海分拨中心/下车扫描 ",
          "time":"2012-08-27 23:22:42",
          "ftime":"2012-08-27 23:22:42",
        }]
  }
请求示例代码:
<?php
    //参数设置
    $post_data = array();
    $post_data["customer"] = '*****';
    $key= '*****' ;
    $post_data["param"] = '{"com":"*****","num":"*****"}';

    $url='http://poll.kuaidi100.com/poll/query.do';
    $post_data["sign"] = md5($post_data["param"].$key.$post_data["customer"]);
    $post_data["sign"] = strtoupper($post_data["sign"]);
    $o="";
    foreach ($post_data as $k=>$v)
    {
        $o.= "$k=".urlencode($v)."&";		//默认UTF-8编码格式
    }
    $post_data=substr($o,0,-1);
    $ch = curl_init();
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_URL,$url);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
        $result = curl_exec($ch);
        $data = str_replace("\"",'"',$result );
        $data = json_decode($data,true);
?>

猜你喜欢

转载自blog.csdn.net/CB_1213/article/details/86637524