import com.baidubce.http.ApiExplorerClient; import com.baidubce.http.AppSigner; import com.baidubce.http.HttpMethodName; import com.baidubce.model.ApiExplorerRequest; import com.baidubce.model.ApiExplorerResponse; // 快递物流查询推送版 Java示例代码 public class RequestDemo { public static void main(String[] args) { String path = "http://gwgp-gebj8indjqc.n.bdcloudapi.com/expresspush"; ApiExplorerRequest request = new ApiExplorerRequest(HttpMethodName.GET, path); request.setCredentials("您的 access key", "您的 secret key"); request.addHeaderParameter("Content-Type", "application/json;charset=UTF-8"); request.addQueryParameter("no", ""); request.addQueryParameter("url", ""); request.addQueryParameter("type", ""); ApiExplorerClient client = new ApiExplorerClient(new AppSigner()); try { ApiExplorerResponse response = client.sendRequest(request); // 返回结果格式为Json字符串 System.out.println(response.getResult()); } catch (Exception e) { e.printStackTrace(); } } }
点击复制代码
{
"orderid": "15596148193983087919",
"status": true,
"code":"300",
"no": "JDVE00023862621",
"type": "JD",
"url": "http:\/\/127.0.0.1\/test.php",
"message": "请求成功,开始推送"
}
{
"orderid": "15596147637548279253",
"status": false,
"code": "104",
"no": "JDVE00023862620",
"type": "JD",
"url": null,
"message": "回调url地址错误,请传递正确url地址"
}
推送示例
{
"code": "OK",
"no": "780098068058",
"type": "ZTO",
"list": [{
"content": "【石家庄市】 快件已在 【长安三部】 签收,签收人: 本人, 感谢使用中通快递,期待再次为您服务!",
"time": "2018-03-09 11:59:26"
}, {
"content": "【石家庄市】 快件已到达 【长安三部】(0311-85344265),业务员 容晓光(13081105270) 正在第1次派件, 请保持电话畅通,并耐心等待",
"time": "2018-03-09 09:03:10"
}, {
"content": "【石家庄市】 快件离开 【石家庄】 发往 【长安三部】",
"time": "2018-03-08 23:43:44"
}, {
"content": "【石家庄市】 快件到达 【石家庄】",
"time": "2018-03-08 21:00:44"
}, {
"content": "【广州市】 快件离开 【广州中心】 发往 【石家庄】",
"time": "2018-03-07 01:38:45"
}, {
"content": "【广州市】 快件到达 【广州中心】",
"time": "2018-03-07 01:36:53"
}, {
"content": "【广州市】 快件离开 【广州花都】 发往 【石家庄中转】",
"time": "2018-03-07 00:40:57"
}, {
"content": "【广州市】 【广州花都】(020-37738523) 的 马溪 (18998345739) 已揽收",
"time": "2018-03-07 00:01:55"
}],
"state": "3",
"msg": "查询成功",
"name": "中通快递",
"site": "www.zto.com",
"phone": "95311",
"logo": "http://img3.fegine.com/express/zto.jpg",
"courier": "容晓光",
"courierPhone": "13081105270"
}
数据接收成功后返回success字符串即可。
(只返回success字符串,具体可参考上述demo)
请求参数:
参数 | 类型 | 是否必须 | 示例值 | 描述 |
no | string | 是 | 454244690951 | 快递单号 【顺丰请输入单号 : 收件人或寄件人手机号后四位。例如:123456789:1234】 |
type | string | 是 | zto | 快递公司代码【共422个见附表】 其他注意:中国邮政分为:邮政包裹【YZPY】 和 邮政速递物流【EMS】,参数EMS是物流,YZPY才是包裹和快递 自动识别不能100%准确 解释:一个单号可对应多个快递公司如:1000745320654,韵达快递,EMS,百世汇通都有该单号记录。 |
url | string | 是 | http://www.fegine.com | 推送的url【公网可以访问的url】 |
返回结果:
参数名称 | 说明 |
orderid | 流水号 |
status | true/false,访问状态 |
no | 快递单号 |
type | 快递公司编码 |
url | 推送的url地址 |
code | 状态代码 |
message | 信息文字说明 |
推送数据字段释义:
参数 | 说明 |
code | -1单号或快递公司错误;201快递单号错误;203 快递公司不存在;204 错误单号重复;205 没有轨迹;207 该单号被限制,错误单号;OK 查询成功 |
no | 订单编号 |
type | 快递公司编码 |
list[] | 结果集数组 |
state | 物流状态:-1:单号或代码错误;0:暂无轨迹;1:快递收件;2:在途中;3:签收;4:问题件 5.疑难件 6.退件签收7:快递收件(揽件) |
time | 物流时间 |
content | 物流描述 |
msg | 提示信息 |
name | 快递名称 |
site | 快递公司官网 |
phone | 快递公司电话 |
logo | 快递公司logo |
状态码(code)
状态码 | 说明 |
101 | 快递单号错误 |
102 | 快递单号或快递公司代码不能为空 |
103 | 快递公司代码错误[请参考产品详情] |
104 | 回调url地址错误,请传递正确url地址 |
201 | url地址访问不通 |
300 | 请求成功,开始推送 |
301 | 重复提交推送请求,已开始推送 |