上门取件-快递鸟在线下单API接口-申通快递
2021-11-09 16:00
本文摘要:前言近几年来,我国电子商务生意业务规模越来越大,线上订单越来越多,退换货的情况也越来越常见。退换货环节是线上购物历程中的重要一环,也是体现电商平台与商家服务水平的重要方面。同时,退换货也是电商平台、商家与消费者之间最容易发生纠纷的环节。 为了保障这个环节的服务,电商平台推出了退换货上门取件业务。退换货上门取件是为买家在退货时,提供的一种省心,便捷的物流服务,当买家购置的商品在申请换货或者提倡维权投诉时需要退货,不需要自己邮寄商品,由物流公司摆设快递员上门取件的一项服务。

AOA国际app

前言近几年来,我国电子商务生意业务规模越来越大,线上订单越来越多,退换货的情况也越来越常见。退换货环节是线上购物历程中的重要一环,也是体现电商平台与商家服务水平的重要方面。同时,退换货也是电商平台、商家与消费者之间最容易发生纠纷的环节。

为了保障这个环节的服务,电商平台推出了退换货上门取件业务。退换货上门取件是为买家在退货时,提供的一种省心,便捷的物流服务,当买家购置的商品在申请换货或者提倡维权投诉时需要退货,不需要自己邮寄商品,由物流公司摆设快递员上门取件的一项服务。目录1.接口功效说明2.完成前期准备事情3.API接口4.请求参数(Headers)5.请求参数(Body)6.请求参数(示例)7.返回参数(Return)8.返回报文(示例)9.完整请求的报文(URL编码)10.解码后的报文11.分步解说(C#版本)12.关于签名1. 接口功效说明此接口用于通知快递公司快递员上门揽件。2.完成前期准备事情去快递鸟官网免费注册一个账号免费获得一个apiKey(接口权限验证需要)完成实名认证流程订购一个免费套餐3.API接口测试挪用地址:http://sandboxapi.kdniao.com:8080/kdniaosandbox/gateway/exterfaceInvoke.json正式挪用地址:http://api.kdniao.com/api/dist请求方式:POST编码花样(utf-8):application/x-www-form-urlencoded;charset=utf-8返回类型:JSON调试页面:http://kdniao.com/UserCenter/v2/SandBox/TrackQuery.aspx调试工具:去调试(使用快递鸟账号登录)接口规则请求报文中不允许泛起以下特殊字符: ' " # & + < > % 预约时提供的收寄方信息必须真实准确。

用户提供的寄件地址若超出快递公司服务规模,则无快递员上门揽件。因用户原因(如:恶意下单、批量下单长时间不发货等)导致快递公司投诉凌驾3次,快递鸟将停用此用户接口权限。预约时间段:上门取件服务时间是9:00~19:00,分为差别的时间片段,9:00~11:00,11:00~13:00,13:00~15:00,15:00~17:00,17:00~19:00,在这期间凭据当前时间选择可选时间段,9点-17点可预约当天上门,17点-越日9点前,预约越日上门全国(除特殊区域):当前时间:9点前 可预约时间段:预约当天任意时间段上门当前时间:11点前 可预约时间段:11点后预约当天任意时间段上门当前时间:13点前 可预约时间段:13点后任意时间段上门当前时间:15点前 可预约时间段:15点后任意时间段上门当前时间:17点前 可预约时间段:17点-19点时间段当前时间:17-越日9点前,预约越日任意时间段上门特殊区域:(西北6省(甘肃、青海、宁夏、陕西、新疆、西藏),东北三省(辽宁省、吉林省、黑龙江省),海南省)当前时间:11点前 可预约时间段:14:00~19:00之间时间段当前时间:11-17点前 可预约时间段:越日9点后任意时间段上门当前时间:17-越日9点前,可预约时间段:越日9点后任意时间段上门4.请求参数(Headers)5.请求参数(Body)6.请求参数(示例){"OrderCode": "012657018199","PayType": "1","MonthCode": "1234567890","ExpType": "1","Sender": {"Name": "Taylor","Mobile": "15018442396","ProvinceName": "上海","CityName": "上海市","Address": "明珠路"},"Receiver": {"Company": "GCCUI","Name": "Yann","Mobile": "15018442396","ProvinceName": "北京","CityName": "北京市","ExpAreaName": "向阳区","Address": "三里屯街道"},"Commodity": [{"GoodsName": "鞋子","Goodsquantity": 1,"GoodsWeight": 1}],"AddService": [{"Name": "COD","Value": "1020","CustomerID": "1234567890"}],"Weight": 1,"Quantity": 1,"Volume": 0,"Remark": "小心轻放","StartDate": "2020-05-19 11:00:00","EndDate": "2020-05-19 15:00:00"}7.返回参数(Return)8.返回报文(示例){ "EBusinessID": "test1617571", "Success": true, "Order": { "OrderCode": "112657018199", "KDNOrderCode": "KDN10200519103057", "ShipperCode": "JD" }, "ResultCode": "100", "Reason": "", "UniquerRequestNumber": "1ed104ea-ff57-404f-8e12-59e1f4636920"}9.完整请求的报文(URL编码)RequestData=%7b++++%22OrderCode%22%3a+%22012657018199%22%2c++++%22PayType%22%3a+%221%22%2c++++%22MonthCode%22%3a+%221234567890%22%2c++++%22ExpType%22%3a+%221%22%2c++++%22Sender%22%3a+%7b++++++++%22Name%22%3a+%22Taylor%22%2c++++++++%22Mobile%22%3a+%2215018442396%22%2c++++++++%22ProvinceName%22%3a+%22%e4%b8%8a%e6%b5%b7%22%2c++++++++%22CityName%22%3a+%22%e4%b8%8a%e6%b5%b7%e5%b8%82%22%2c++++++++%22Address%22%3a+%22%e6%98%8e%e7%8f%a0%e8%b7%af%22++++%7d%2c++++%22Receiver%22%3a+%7b++++++++%22Company%22%3a+%22GCCUI%22%2c++++++++%22Name%22%3a+%22Yann%22%2c++++++++%22Mobile%22%3a+%2215018442396%22%2c++++++++%22ProvinceName%22%3a+%22%e5%8c%97%e4%ba%ac%22%2c++++++++%22CityName%22%3a+%22%e5%8c%97%e4%ba%ac%e5%b8%82%22%2c++++++++%22ExpAreaName%22%3a+%22%e6%9c%9d%e9%98%b3%e5%8c%ba%22%2c++++++++%22Address%22%3a+%22%e4%b8%89%e9%87%8c%e5%b1%af%e8%a1%97%e9%81%93%22++++%7d%2c++++%22Commodity%22%3a+%5b++++++++%7b++++++++++++%22GoodsName%22%3a+%22%e9%9e%8b%e5%ad%90%22%2c++++++++++++%22Goodsquantity%22%3a+1%2c++++++++++++%22GoodsWeight%22%3a+1++++++++%7d++++%5d%2c++++%22AddService%22%3a+%5b++++++++%7b++++++++++++%22Name%22%3a+%22COD%22%2c++++++++++++%22Value%22%3a+%221020%22%2c++++++++++++%22CustomerID%22%3a+%221234567890%22++++++++%7d++++%5d%2c++++%22Weight%22%3a+1%2c++++%22Quantity%22%3a+1%2c++++%22Volume%22%3a+0%2c++++%22Remark%22%3a+%22%e5%b0%8f%e5%bf%83%e8%bd%bb%e6%94%be%22%2c++++%22StartDate%22%3a+%222020-05-19+11%3a00%3a00%22%2c++++%22EndDate%22%3a+%222020-05-19+15%3a00%3a00%22%7d&EBusinessID=test1617571&RequestType=1801&DataSign=MjRkM2ZjYWNhYzMyOGQ4M2U5ZDhjZmQxNTZjNTMxY2M%3d&DataType =210.解码后的报文:RequestData={"PayType": 1,"ExpType": 1,"ShipperCode": "SF","OrderCode": "300008886539888", "IsNotice": 1,"IsReturnPrintTemplate": 1,"Commodity": [{"GoodsName": "其他","Goodsquantity": 1,"GoodsWeight": 0}],"Sender": {"Name": "王宝剑","Mobile": "13988888888","ProvinceName": "北京市","CityName": "北京市","ExpAreaName": "西城区","Address": "北京市西城区西直门南小街国英1号1020"},"Receiver": {"Name": "刘小刀","Mobile": "18809999999","ProvinceName": "广东省","CityName": "深圳市","ExpAreaName": "福田区","Address": "广东省深圳市福田区华宝一号大厦"}}&EBusinessID=test1617571&RequestType=1007&DataSign=ZDhhOTU2OTcxMWI1NGFiNTBmMzQ5NjMwNzYxZmEyMzk=&DataType=211.分步解说(C#版本)请求数据包结构12 .签名说明关于签名快递鸟和第三方电子商务公司系统举行对接,有一定的宁静机制。

接纳IP认证加签名的方式对接,详细方案如下:1.防止数据被窜改在POST请求中会通报5个必须(R)参数RequestData==数据内容(URL编码:UTF-8)EBusinessID==用户IDRequestType=请求指令类型DataSign== 数据内容签名:把(请求内容(未编码)+ApiKey)举行MD5加密,然后Base64编码,最后举行URL(utf-8)编码DataType==2(返回数据类型为json)注:DataSign生成后,对方吸收到数据后,以同样的算法举行签名(推送接口RequestType为101/102不需要举行URL编码),生成摘要,对比两者的摘要是否相同,如果差别,说明通报历程中发生数据窜改。2.挪用接口的身份认证注册成为快递鸟用户后,会生成对应的用户ID和APIKey,用户ID相当于用户名,APIKey相当于密码。

举例:1.假设RequestData (JSON)内容为:{'OrderCode':'','ShipperCode':'SF','LogisticCode':'118954907573'}经由URL(UTF-8)编码的内容为:%7b%27OrderCode%27%3a%27%27%2c%27ShipperCode%27%3a%27SF%27%2c%27LogisticCode%27%3a%27118954907573%27%7d;EBusinessID=1237100【示例ID,不行用来实际使用】APIKey=56da2cf8-c8a2-44b2-b6fa-476cd7d1ba17【示例Key,不行用来实际使用】2.那么DataSign签名的内容为{'OrderCode':'','ShipperCode':'SF','LogisticCode':'118954907573'}56da2cf8-c8a2-44b2-b6fa-476cd7d1ba17经由md5和base64后的内容就为:OWFhM2I5N2ViM2U2MGRkMjc4YzU2NmVlZWI3ZDk0MmE=,在经由URL(UTF-8)编码的内容为:OWFhM2I5N2ViM2U2MGRkMjc4YzU2NmVlZWI3ZDk0MmE%3d最终要发送的数据为:RequestType=1002&EBusinessID=1237100&RequestData =%7b%27OrderCode%27%3a%27%27%2c%27ShipperCode%27%3a%27SF%27%2c%27LogisticCode%27%3a%27118954907573%27%7d&DataSign=OWFhM2I5N2ViM2U2MGRkMjc4YzU2NmVlZWI3ZDk0MmE%3d&DataType=23.吸收方收到数据后,获得EBusinessID 和RequestData和DataSign等这几个数据。4.吸收方对EBusinessID 获得APIKey,RequestData+APIKey的数据举行md5和base64后的内容就为OWFhM2I5N2ViM2U2MGRkMjc4YzU2NmVlZWI3ZDk0MmE=5.吸收方判断签名后的数据跟通报过来的DataSign是否一致,如果一致举行业务操作,如果纷歧致返回错误。

接口挪用示例:string used = "1237100";//仅作为示例ID,不行用来实际使用//加密私钥,由快递鸟提供string keyValue = "56da2cf8-c8a2-44b2-b6fa-476cd7d1ba17";//仅作为示例Key,不行用来实际使用//请求地址string url = "http://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx";//2-jsonstring DataType = "2";//字符编码接纳UTF-8string charset = "UTF-8";//JSON字符串stringstring jsonStr = "json请求报文";//把(jsonStr+APIKey)举行MD5加密,然后Base64编码,最后 举行URL(utf-8)编码datasign = HttpUtility.UrlEncode(base64(MD5(jsonStr + keyValue, "UTF-8"), "UTF-8"), Encoding.UTF8);//请求报文参数string PostStr = "RequestType=1002&EBusinessID= used &RequestData=jsonStr &DataSign= datasign&DataType=DataType";//通讯协议使用Http协议Post请求方式string post = this.DoPost(url, PostStr);C#挪用方法:///<summary> /// 字符串MD5加密 ///</summary> ///<param name="str">要加密的字符串</param> ///<param name="charset">编码方式</param> ///<returns>密文</returns> private string MD5(string str, string charset) { byte[] buffer = System.Text.Encoding.GetEncoding(charset).GetBytes(str); try { System.Security.Cryptography.MD5CryptoServiceProvider check; check = new System.Security.Cryptography.MD5CryptoServiceProvider(); byte[] somme = check.ComputeHash(buffer); string ret = ""; foreach (byte a in somme) { if (a < 16) ret += "0" + a.ToString("X"); else ret += a.ToString("X"); } return ret.ToLower(); } catch { throw; } } /// <summary> /// base64编码 /// </summary> /// <param name="str">内容</param> /// <param name="charset">编码方式</param> /// <returns></returns> private string base64(String str, String charset) { return Convert.ToBase64String(System.Text.Encoding.GetEncoding(charset).GetBytes(str));} /// <summary> /// Post方式提交数据,返回网页的源代码 /// </summary> /// <param name="url">发送请求的 URL</param> /// <param name="postData">请求报文参数</param> /// <returns>远程资源的响应效果</returns> private string SendPost(string url, string postData) { string result = ""; byte[] byteData = Encoding.GetEncoding("UTF-8").GetBytes(postData.ToString()); try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.ContentType = "application/x-www-form-urlencoded"; request.Referer = url; request.Accept = "*/*"; request.Timeout = 30 * 1000; request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)"; request.Method = "POST"; request.ContentLength = byteData.Length; Stream stream = request.GetRequestStream(); stream.Write(byteData, 0, byteData.Length); stream.Flush(); stream.Close(); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream backStream = response.GetResponseStream(); StreamReader sr = new StreamReader(backStream, Encoding.GetEncoding("UTF-8")); result = sr.ReadToEnd(); sr.Close(); backStream.Close(); response.Close(); request.Abort(); } catch (Exception ex) { result = ex.ToString(); } return result; }。


本文关键词:AOA体育官网APP,上门,取件,快递,鸟,在线,下单,API,接口,申通

本文来源:AOA体育官网APP-www.tongzhouxian.com