博客列表 >电子面单接口demo:京东,中通,圆通,申通,韵达,天天,百世,邮政,顺丰,德邦一次性接入

电子面单接口demo:京东,中通,圆通,申通,韵达,天天,百世,邮政,顺丰,德邦一次性接入

快递100API
快递100API原创
2021年08月10日 15:24:011253浏览

快递100API电子面单接口可支持45+家快递公司(四通一达、百世、邮政、顺丰、德邦等)。并且可与顺丰对接,与顺丰对接时可选择使用顺丰的电子面单服务或者快递100API的电子面单服务。

快递100API为独立电商、仓储和物流等系统平台提供电子面单接口,客户在快递100API网络上选择快递公司并进行在线发货。如需查看官方技术文档请访问:https://api.kuaidi100.com/document/5eb9f5b686b0df41883139f4.html

方便开发者实现:运营前端下单寄件后自动自动生成电子面单、发货单、营销物料——>仓储人员自动获取运营生成的电子面单、发货单、营销物料并完成包装。

语言:java

电子面单API产品介绍

电子面单API支持45+家快递公司网点面单打印、主流电商平台(淘宝、京东、拼多多)面单打印以及国际快递公司面单打印。具体列表清查看参数字典

  1. /**
  2. * 电子面单图片接口
  3. */
  4. @Test
  5. public void testPrintImg() throws Exception{
  6. PrintImgParam printImgParam = new PrintImgParam();
  7. printImgParam.setKuaidicom(CompanyConstant.ZJS);
  8. printImgParam.setSendManName("张三");
  9. printImgParam.setSendManMobile("15999566666");
  10. printImgParam.setSendManPrintAddr("广东省深圳市南山区科技南十二路");
  11. printImgParam.setRecManName("李四");
  12. printImgParam.setRecManMobile("15999566666");
  13. printImgParam.setRecManPrintAddr("北京市海淀区xxx路");
  14. printImgParam.setType("10");
  15. printImgParam.setTempid("180c7c8f646742ca871a92c976392b05");
  16. printImgParam.setCount("1");
  17. String param = new Gson().toJson(printImgParam);
  18. String t = System.currentTimeMillis() + "";
  19. String sign = SignUtils.printSign(param,t,key,secret);
  20. PrintReq printReq = new PrintReq();
  21. printReq.setKey(key);
  22. printReq.setMethod(ApiInfoConstant.ELECTRONIC_ORDER_PIC_METHOD);
  23. printReq.setSign(sign);
  24. printReq.setParam(param);
  25. printReq.setT(t);
  26. IBaseClient printImg = new PrintImg();
  27. System.out.println(printImg.execute(printReq));
  28. }
  1. /**
  2. * 电子面单html接口
  3. */
  4. @Test
  5. public void testPrintHtml() throws Exception{
  6. ManInfo recManInfo = new ManInfo();
  7. recManInfo.setName("张三");
  8. recManInfo.setMobile("15999566666");
  9. recManInfo.setPrintAddr("广东省深圳市南山区科技南十二路");
  10. ManInfo sendManInfo = new ManInfo();
  11. sendManInfo.setName("李四");
  12. sendManInfo.setMobile("15999566666");
  13. sendManInfo.setPrintAddr("北京市海淀区xxx路");
  14. PrintHtmlParam printHtmlParam = new PrintHtmlParam();
  15. printHtmlParam.setKuaidicom(CompanyConstant.ZJS);
  16. printHtmlParam.setCount(2);
  17. printHtmlParam.setNeedChild(1);
  18. //如果需要返回电子面单,需要设置
  19. printHtmlParam.setNeedTemplate("1");
  20. printHtmlParam.setSendMan(sendManInfo);
  21. printHtmlParam.setRecMan(recManInfo);
  22. String t = System.currentTimeMillis() + "";
  23. String param = new Gson().toJson(printHtmlParam);
  24. String sign = SignUtils.printSign(param,t,key,secret);
  25. PrintReq printReq = new PrintReq();
  26. printReq.setKey(key);
  27. printReq.setMethod(ApiInfoConstant.ELECTRONIC_ORDER_HTML_METHOD);
  28. printReq.setT(t);
  29. printReq.setSign(sign);
  30. printReq.setParam(param);
  31. IBaseClient printHtml = new PrintHtml();
  32. System.out.println(printHtml.execute(printReq));
  33. }
  1. /**
  2. * 电子面单打印
  3. */
  4. @Test
  5. public void testPrintCloud() throws Exception{
  6. ManInfo recManInfo = new ManInfo();
  7. recManInfo.setName("张三");
  8. recManInfo.setMobile("15999566666");
  9. recManInfo.setPrintAddr("广东省深圳市南山区科技南十二路");
  10. ManInfo sendManInfo = new ManInfo();
  11. sendManInfo.setName("李四");
  12. sendManInfo.setMobile("15999566666");
  13. sendManInfo.setPrintAddr("北京市海淀区xxx路");
  14. PrintCloudParam printCloudParam = new PrintCloudParam();
  15. printCloudParam.setKuaidicom(CompanyConstant.ZJS);
  16. printCloudParam.setCount("1");
  17. printCloudParam.setSiid(siid);
  18. printCloudParam.setTempid("180c7c8f646742ca871a92c976392b05");
  19. printCloudParam.setSendMan(sendManInfo);
  20. printCloudParam.setRecMan(recManInfo);
  21. String param = new Gson().toJson(printCloudParam);
  22. String t = System.currentTimeMillis() + "";
  23. PrintReq printReq = new PrintReq();
  24. printReq.setT(t);
  25. printReq.setKey(key);
  26. printReq.setMethod(ApiInfoConstant.ELECTRONIC_ORDER_PRINT_METHOD);
  27. printReq.setSign(SignUtils.printSign(param,t,key,secret));
  28. printReq.setParam(param);
  29. IBaseClient baseClient = new PrintCloud();
  30. System.out.println(baseClient.execute(printReq));
  31. }
  1. /**
  2. * 云打印自定义
  3. */
  4. @Test
  5. public void testCloudCustom() throws Exception{
  6. CloudPrintCustomParam cloudPrintCustomParam = new CloudPrintCustomParam();
  7. cloudPrintCustomParam.setSiid(siid);
  8. cloudPrintCustomParam.setCallBackUrl("http://www.baidu.com");
  9. cloudPrintCustomParam.setTempid("180c7c8f646742ca871a92c976392b05");
  10. String t = System.currentTimeMillis() + "";
  11. String param = new Gson().toJson(cloudPrintCustomParam);
  12. PrintReq printReq = new PrintReq();
  13. printReq.setKey(key);
  14. printReq.setMethod(ApiInfoConstant.CLOUD_PRINT_CUSTOM_METHOD);
  15. printReq.setT(t);
  16. printReq.setSign(SignUtils.printSign(param,t,key,secret));
  17. printReq.setParam(param);
  18. IBaseClient baseClient = new CloudPrintCustom();
  19. System.out.println(baseClient.execute(printReq));
  20. }
  1. /**
  2. * 云打印附件
  3. */
  4. @Test
  5. public void testCloudAttachment() throws Exception{
  6. CloudPrintAttachmentParam cloudPrintAttachmentParam = new CloudPrintAttachmentParam();
  7. cloudPrintAttachmentParam.setSiid(siid);
  8. cloudPrintAttachmentParam.setCallBackUrl("http://www.baidu.com");
  9. String t = System.currentTimeMillis() + "";
  10. String param = new Gson().toJson(cloudPrintAttachmentParam);
  11. CloudAttachmentReq cloudPrintAttachmentReq = new CloudAttachmentReq();
  12. cloudPrintAttachmentReq.setKey(key);
  13. cloudPrintAttachmentReq.setMethod(ApiInfoConstant.CLOUD_PRINT_ATTACHMENT_METHOD);
  14. cloudPrintAttachmentReq.setT(t);
  15. cloudPrintAttachmentReq.setSign(SignUtils.printSign(param,t,key,secret));
  16. cloudPrintAttachmentReq.setParam(param);
  17. cloudPrintAttachmentReq.setFile(new File("C:\\Users\\Administrator.-20171106WFEKLN\\Desktop\\1.jpg"));
  18. IBaseClient baseClient = new CloudPrintAttachment();
  19. System.out.println(baseClient.execute(cloudPrintAttachmentReq));
  20. }
  1. /**
  2. * 复打
  3. */
  4. @Test
  5. public void testCloudPrintOld() throws Exception{
  6. PrintReq printReq = new PrintReq();
  7. CloudPrintOldParam cloudPrintOldParam = new CloudPrintOldParam();
  8. cloudPrintOldParam.setTaskId("D21DB1AC74A260E6F5604FC43B4598B8");
  9. String t = System.currentTimeMillis() + "";
  10. String param = new Gson().toJson(cloudPrintOldParam);
  11. printReq.setKey(key);
  12. printReq.setMethod(ApiInfoConstant.CLOUD_PRINT_OLD_METHOD);
  13. printReq.setT(t);
  14. printReq.setSign(SignUtils.printSign(param,t,key,secret));
  15. printReq.setParam(param);
  16. IBaseClient cloudPrintOld = new CloudPrintOld();
  17. System.out.println(cloudPrintOld.execute(printReq));
  18. }
  1. /**
  2. * 发送短信
  3. */
  4. @Test
  5. public void testSendSms() throws Exception{
  6. SendSmsReq sendSmsReq = new SendSmsReq();
  7. sendSmsReq.setCallback("http://www.baidu.com");
  8. Map<String,String> content = new HashMap<String, String>();
  9. content.put("username","测试用户");
  10. sendSmsReq.setContent(new Gson().toJson(content));
  11. sendSmsReq.setPhone("15994708912");
  12. sendSmsReq.setSeller("贵司名称");
  13. sendSmsReq.setUserid(userid);
  14. sendSmsReq.setTid(tid);
  15. sendSmsReq.setSign(SignUtils.smsSign(key,userid));
  16. IBaseClient sendSms = new SendSms();
  17. System.out.println(sendSms.execute(sendSmsReq));
  18. }

官方技术支持:https://api.kuaidi100.com/document/5eb9f5b686b0df41883139f4.html

声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议