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-jbvaqrrwly2.n.bdcloudapi.com/globalExpressLists"; ApiExplorerRequest request = new ApiExplorerRequest(HttpMethodName.GET, path); request.setCredentials("您的 access key", "您的 secret key"); request.addHeaderParameter("Content-Type", "application/json;charset=UTF-8"); 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(); } } }
点击复制代码
{"status":"200","msg":"success","result":{"SF":"顺丰速运"}}
请求参数:
参数 | 类型 | 是否必须 | 示例值 | 描述 |
n | string | 是 | 454244690951 | 快递单号 【顺丰请输入运单号 : 收件人或寄件人手机号后四位。例如:123456789:1234】 |
t | string | 是 | zto | 快递公司代码【共422个见附表】 其他注意:中国邮政分为:邮政包裹【YZPY】 和 邮政速递物流【EMS】,参数EMS是物流,YZPY才是包裹和快递, |
返回结果:
参数名称 | 类型 | 示例值 | 说明 |
OrderCode | String | 454244690951 | 物流快递运单号 |
ShipperCode | String | ZTO | 快递公司编码 |
Traces | array | [...] | 快递物流轨迹 |
AcceptStation | String | [武汉市] [中吉武汉仓]的鑫源泽数码专营店已收件 | 快递中转站,终点站 |
AcceptTime | String | 2017-09-17 13:52:50 | 事件时间 |
State | String | 3 | 物流状态:-1:单号或快递公司代码错误, 0:暂无轨迹, 1:快递收件(揽件),2:在途中,3:签收,4:问题件 5.疑难件 6.退件签收 |
Success | boolean | true | 成功与否 |
courier | String | 容晓光 | 快递员 或 快递站(没有则为空) |
courierPhone | String | 13081105XX0 | 快递员电话 (没有则为空) |
updateTime | String | 容晓光 | 快递轨迹信息最新时间 |
takeTime | String | 2天20小时14分 | 发货到收货消耗时长 (截止最新轨迹) |
快递投递状态码(State)
状态码 | 说明 |
-1 | 单号或代码错误 |
0 | 暂无轨迹 |
1 | 快递收件 |
2 | 在途中 |
3 | 签收 |
4 | 问题件 |
5 | 疑难件(收件人拒绝签收,地址有误或不能送达派送区域,收费等原因无法正常派送) |
6 | 退件签收 |
7 | 快递收件(揽件) |
快递查询