快递100物流查询接口的实现

一、首先去快递100页面注册唯一性ID

二、选择自己觉得好用的接口,(有一个接口很坑,主流的快递都不能查询),大家注意

三、代码块

//获得快递100的查询地址
private String searchkuaiDiInfo(String id)
{
OrderForm obj = this.orderFormService
.getObjById(CommUtil.null2Long(id));
String content = "";
try{
URL url = new URL("http://www.kuaidi100.com/applyurl?key="
+ this.configService.getSysConfig().getKuaidi_id()
+ "&com="
+ (obj.getEc() != null ? obj.getEc().getCompany_mark() : "")
+ "&nu="
+ obj.getShipCode()
);
URLConnection con = url.openConnection();
con.setAllowUserInteraction(false);
InputStream urlStream = url.openStream();
byte b[] = new byte[10000];
int numRead = urlStream.read(b);
content = new String(b, 0, numRead);
while (numRead != -1)
{
numRead = urlStream.read(b);
if (numRead != -1)
{
// String newContent = new String(b, 0, numRead);
String newContent = new String(b, 0, numRead, "UTF-8");
content += newContent;
}
}
urlStream.close();
} catch (Exception e)
{
e.printStackTrace();
}
//System.out.println(content);
return content;
}



这儿是根据快递单号获取快递信息,快递100返回的是一个地址,然后,我们开发人员将这个地址嵌入到自己的页面即可,完了我们就可以看到对应的快递编号的物流信息了,这个页面有快递100的广告。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值