使用java调用快递100的API接口查询快递信息
/** * 根据快递单号查询数据信息 * @param kuaidiNo * @return */ public static String getExpressInfo(String kuaidiNo){ StringBuffer content = new StringBuffer(); String url_1 = "http://www.kuaidi100.com/autonumber/autoComNum?text="+kuaidiNo; String response_1 = getResponse(url_1); String response_2 =""; ExpressEntity en = JSON.parseObject(response_1,ExpressEntity.class); int size = en.getAuto().size(); if(size==0){ content.append("<html><h2 style='color:red;text-align:center;'>抱歉,暂无查询记录!</h2><h3 style='color:blue;text-align:center;'>请确保您输入了正确的快递单号!</h3></html>"); }else{ String comCode = en.getAuto().get(0).getComCode(); String url_2 = "http://www.kuaidi100.com/query?type="+comCode+"&postid="+kuaidiNo+"&id=1&valicode=&temp=0.4189816807753606"; response_2 = getResponse(url_2);//拿到快递100返回的 信息 } return response_2; }