Net source code "express bird API"
Stillness Speaks 2020-11-25 23:59:46
Retail e-commerce platform and ISV Business to logistics api There are many requirements for interfaces , Today we mainly share is the docking guide of express bird express bill number query interface , There are many application scenarios for the interface of express bill number query , A lot of scenes will come across , The most important thing is that users of e-commerce websites open “ My order ” Call this API Display logistics information details , E-commerce management background logistics system , Customer service checks the status of all waybills before reconciliation , And track the problem , E-commerce platform controls business logistics , Requirements must be in how long the express must be sent to see the status of the pickup , How long must we receive the goods and see the sign in status , According to these States, the business is controlled to improve the overall satisfaction of users .

 Express bill number query interface docking C# course .net Source code 「 Express bird API」


Call express bird express order number query API Interface , You can find out 600 More than one express company order number from the receipt of 、 transport , To transfer center , The status of delivery and delivery . Express bird api Interfaces don't differentiate between development languages , Support Java,C#,PHP,Python,ObjectC Call the program development language . The implementation process is explained in detail below :

Docking process


1、 Send express bill number and express company code to express bird

2、 Express bird according to the order number and express company query logistics track status

3、 Express bird will query the status of logistics trajectory to the e-commerce platform or ISV Service provider

4、 E-commerce platform or ISV Service providers receive data and process data in real time for data display or application


 Express bill number query interface docking C# course .net Source code 「 Express bird API」

Interface description


(1) Query interface supports query according to waybill No ( Single query ). (2) The interface needs to specify the express company code of express bill No , If the format is wrong or the code is wrong, the failure message will be returned . Such as :EMS The logistics order number shall be express company code (EMS) Check and download express bird express company code (3) The returned logistics tracking information is arranged in ascending order according to the time of occurrence . (4) Interface instructions 1002. (5) The message receiving method supported by the interface is HTTP POST, The encoding format of the request method (utf-8):"application/x-www-form-urlencoded;charset=utf-8". (6) Test call address :http://sandboxapi.kdniao.com:8080/kdniaosandbox/gateway/exterfaceInvoke.json (7) Official call address :http://api.kdniao.com/api/dist

(8) Return type :JSON

(9) Debug page :http://kdniao.com/UserCenter/v2/SandBox/TrackQuery.aspx

(10) Debugging tools : To debug ( Log in with your express bird account )

Request system level parameter description :


 Express bill number query interface docking C# course .net Source code 「 Express bird API」


remarks :R- Required (Required),O- Optional (Optional),C- The parameter in the message is optional under certain conditions (Conditional)

【 Interface parameters 】

Request content field definition :

 Express bill number query interface docking C# course .net Source code 「 Express bird API」


Return parameter definition :


 Express bill number query interface docking C# course .net Source code 「 Express bird API」

Example


Request example JSON
{ "OrderCode": "", "ShipperCode": "SF", "LogisticCode": "118650888018" }

Return to example JSON
 There is no logistics track { "EBusinessID": "1109259", "Traces": [], "OrderCode": "", "ShipperCode": "SF", "LogisticCode": "118461988807", "Success": false, "Reason": null } Having a logistics track { "EBusinessID": "1109259", "OrderCode": "", "ShipperCode": "SF", "LogisticCode": "118461988807", "Success": true, "State": 3, "Reason": null, "Traces": [ { "AcceptTime": "2014/06/25 08:05:37", "AcceptStation": " I'm sending a ..( Send someone : Deng Yufu , Telephone :18718866310)[ Shenzhen City ]", "Remark": null }, { "AcceptTime": "2014/06/25 04:01:28", "AcceptStation": " The express is in Shenzhen distribution center , Ready to go to the next station Shenzhen [ shenzhen ]", "Remark": null }, { "AcceptTime": "2014/06/25 01:41:06", "AcceptStation": " The express is in Shenzhen distribution center [ shenzhen ]", "Remark": null }, { "AcceptTime": "2014/06/24 20:18:58", "AcceptStation": " Received [ shenzhen ]", "Remark": null }, { "AcceptTime": "2014/06/24 20:55:28", "AcceptStation": " The express is in Shenzhen , Ready to go to the next station Shenzhen distribution center [ shenzhen ]", "Remark": null }, { "AcceptTime": "2014/06/25 10:23:03", "AcceptStation": " The dispatch has been signed in [ shenzhen ]", "Remark": null }, { "AcceptTime": "2014/06/25 10:23:03", "AcceptStation": " The receiver is : Signed for [ shenzhen ]", "Remark": null } ] }

Preparatory work


Go to express bird official website to register an account for free , Get one for free apiKey( Interface authority verification requires ), Complete the real name authentication process , Order a free or paid package ( You can also find express bird staff to apply for free interface test joint debugging )

Express bird technology development document download express bird DEMO download

notes : Login express bird user management background Get users ID and APIKey Corresponding to each demo Medium EBusinessID、AppKey.

Little knowledge :EBusinessID Follow APIKey What is it? ?EBusinessID Follow APIKey The key that express bird distributes after you register in express bird website ( Corresponding to the users on the official website ID and API key), To ensure the reliability of the application source , Avoid using forgery , Be used illegally .

Request complete message ( Example )

RequestData=%7b%27OrderCode%27%3a%27%27%2c%27ShipperCode%27%3a%27JTSD%27%2c%27LogisticCode%27%3a%27jt0000052600488%27%7d&EBusinessID=1264783&RequestType=1002&DataSign=MTYyMDU4NWQ2NmU1ZDI2MDEzNGE5YmVlM2YxYzEzMTM%3d&DataType=2

Message returned successfully ( Example )

{"LogisticCode": "JT0000052600488","ShipperCode": "JTSD","Traces": [{"AcceptStation": "【 Wuhu City 】【 Wuhu Jinghu network 】 Deng Yongjun 17855364213 The piece has been taken ","AcceptTime": "2020-03-16 16:26:13"},{"AcceptStation": "【 Wuhu City 】【 Wuhu Jinghu network 】 Deng Yongjun 17855364213 The piece has been taken ","AcceptTime": "2020-03-16 16:41:33"},{"AcceptStation": "【 Wuhu City 】【 Wuhu Jinghu network 】 Received ","AcceptTime": "2020-03-16 17:39:21"},{"AcceptStation": "【 Wuhu City 】 Leave by express 【 Wuhu Jinghu network 】 Has been sent to 【 Wuhu Transfer Center 】","AcceptTime": "2020-03-16 17:40:27"},{"AcceptStation": "【 Wuhu City 】 The express arrived 【 Wuhu Transfer Center 】","AcceptTime": "2020-03-16 19:36:32"},{"AcceptStation": "【 Wuhu City 】 Leave by express 【 Wuhu Transfer Center 】 Has been sent to 【 Hefei Transfer Center 】","AcceptTime": "2020-03-16 20:47:03"},{"AcceptStation": "【 Hefei 】 The express arrived 【 Hefei Transfer Center 】","AcceptTime": "2020-03-16 23:40:10"},{"AcceptStation": "【 Hefei 】 Leave by express 【 Hefei Transfer Center 】 Has been sent to 【 Guangzhou Huadu Transfer Center 】","AcceptTime": "2020-03-17 00:10:48"},{"AcceptStation": "【 guangzhou 】 The express arrived 【 Guangzhou Huadu Transfer Center 】","AcceptTime": "2020-03-17 20:45:00"},{"AcceptStation": "【 guangzhou 】 Leave by express 【 Guangzhou Huadu Transfer Center 】 Has been sent to 【 Shenzhen Bao'an Transfer Center 】","AcceptTime": "2020-03-18 00:17:55"},{"AcceptStation": "【 shenzhen 】 The express arrived 【 Shenzhen Bao'an Transfer Center 】","AcceptTime": "2020-03-18 03:00:17"},{"AcceptStation": "【 shenzhen 】 Leave by express 【 Shenzhen Bao'an Transfer Center 】 Has been sent to 【 Shenzhen Futian branch 】","AcceptTime": "2020-03-18 04:44:39"},{"AcceptStation": "【 shenzhen 】【 Shenzhen Futian branch 】 Zou Junlin 17679495647 I'm sending a ","AcceptTime": "2020-03-18 08:10:09"},{"AcceptStation": "【 shenzhen 】【 Shenzhen Futian branch 】 Zhao Kai 15919817730 I'm sending a ","AcceptTime": "2020-03-18 09:55:19"},{"AcceptStation": "【 shenzhen 】 The express has been signed for , The receiver is 【 Collect on behalf of 】, If you have any questions, please contact :15919817730, Looking forward to serving you again ","AcceptTime": "2020-03-18 14:53:54"}],"State": "3","EBusinessID": "1264783","Success": true}

Failure return message ( Example )

{"LogisticCode": "JT0000052600488","ShipperCode": "JTSD","Traces": [],"State": "0","EBusinessID": "1264783","Reason": " Business error [ No packages available ]","Success": false}

explain : No real name authentication , No package ordered , The number of available queries for the package has been used up Will return this message information Go to real name authentication / Learn more about the package

No trace return message ( Example )

{"LogisticCode": "JT0000052600488","ShipperCode": "JTSD","Traces": [],"State": "0","EBusinessID": "1264783","Reason": " No track information at the moment ","Success": true}

Step by step (C# edition ) Request packet structure


 Express bill number query interface docking C# course .net Source code 「 Express bird API」

C# Call code example

// Online retailers IDstring eEBusinessID = "test1617571"; // E-commerce encryption private key , Express bird offers , Take care of , Don't leak string appKey= "554343b2-7252-439b-b4eb-1af42c8f2175"; // request urlstring reqURL = "http://sandboxapi.kdniao.com:8080/kdniaosandbox/gateway/exterfaceInvoke.json";// Request instructions string reqType="1002";//2-json string dataType = "2"; // Character encoding adopts UTF-8 string charset = "UTF-8"; //JSON character string string string jsonStr = "{\"OrderCode\":\"\",\"ShipperCode\":\"JTSD\",\"LogisticCode\":\"JT0000052600488\"}" ;// hold (jsonStr+APIKey) Conduct MD5 encryption string md5Str=MD5(jsonStr + apiKey, charset);// hold md5Str Conduct Base64 code string base64Str=base64(md5Str,charset);// Conduct URL code (utf-8)string datasign = HttpUtility.UrlEncode(base64Str, charset); // Request message parameters string postStr = "RequestType=reqType&EBusinessID= eEBusinessID&RequestData=jsonStr &DataSign= datasign&DataType=dataType"; // Communication protocol use Http agreement Post Request mode Return trajectory data string post = SendPost(reqURL, postStr);// Acquired post The data is the complete message returned by the express bird , Next, write an analysis by yourself json You can get the information of the fields in it .

C# Calling method

///<summary> /// character string MD5 encryption ///</summary> ///<param name="str"> The string to encrypt </param> ///<param name="charset"> Encoding mode </param> ///<returns> Ciphertext </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 code /// </summary> /// <param name="str"> Content </param> /// <param name="charset"> Encoding mode </param> /// <returns></returns> private string base64(String str, String charset) { return Convert.ToBase64String(System.Text.Encoding.GetEncoding(charset).GetBytes(str));} /// <summary> /// Post How to submit data , Return the source code of the web page /// </summary> /// <param name="url"> Send requested URL</param> /// <param name="postData"> Request message parameters </param> /// <returns> Remote resource response results </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; }

Express order number query interface application effect


 Express bill number query interface docking C# course .net Source code 「 Express bird API」


Finish can achieve the express official website display effect .

About the signature


Express bird and third-party e-commerce company system docking , There are certain security mechanisms . use IP Authentication and signature The way of docking , The specific scheme is as follows :
 Prevent data from being tampered with stay POST The request will pass 5 It's a must (R) Parameters RequestData== The data content (URL code :UTF-8) EBusinessID== user ID RequestType= Request instruction type DataSign== Data content signature : hold ( Request content ( No encoding )+ApiKey) Conduct MD5 encryption , then Base64 code , The last part URL(utf-8) code DataType==2( The return data type is json) notes :DataSign After generation , After receiving the data , Sign with the same algorithm ( Push interface RequestType by 101/102 There is no need for URL code ), Generate summary , Compare the abstracts of the two , If different , Data tampering occurred in the process of transmission . Authentication of calling interface After registering as an express bird user , The corresponding user will be generated ID and APIKey, user ID Equivalent to user name , APIKey Equivalent to password .

13. Return code definition




 Express bill number query interface docking C# course .net Source code 「 Express bird API」

14、 About sandbox debugging


Configure callback address in sandbox debugging platform , Test push interface . The callback address is provided by the user , It is used to receive logistics information pushed by express birds , As long as you can visit the Internet . test 、 The configuration steps are as follows :

( Sandbox debugging platform address :http://kdniao.com/UserCenter/v2/SandBox/PushQueryParam.aspx)

a、 Fill in the callback address :

 Express bill number query interface docking C# course .net Source code 「 Express bird API」


b、 Click on 【 Generate 】 after Application level parameter message (RequestData) It is to push the test logistics information on the callback address filled in by the user in the first step .

c、 Click on 【 call 】, After the user receives the test logistics information , Users need to Application level parameter message area Return the successful received signal to the express bird ( notes : There should be no spaces between fields , The space will affect the returned result ),

Returns the format :{"EBusinessID":"1237100","UpdateTime":"2015-03-11 16:26:11","Success":true,"Reason": ""}

 Express bill number query interface docking C# course .net Source code 「 Express bird API」


d、 The call result shows that after the request is successful, the push interface developed by the user passes the test .

e、 After passing the test, go back to the first step to fill in the callback address and click 【 To configure 】, Pop up the pop-up box , Fill in the mobile number ( It must be the mobile phone number of the registered express bird account )、 Verification Code 、

token url , Click on 【 preservation 】 If the configuration is successful, it can be used in the formal environment , If you need to modify the callback address next time, the steps are the same as the first time to configure the callback address .

 Express bill number query interface docking C# course .net Source code 「 Express bird API」

Other instructions in docking


1、 Logistics query ( Free version ) The membership package is a free version , The period of validity 1 At the end of the year , If near 3 Within months, the data exchange system will automatically renew for free ;

2、 Instant query (RequestType:1002/8001) Number of queries per day <=3000 Second docking instant query interface

3、 Real name authentication is required before requesting an interface , Open related member services , Otherwise, the request fails and a prompt is returned “ No application to open the interface ”;

4、 Interface development can be downloaded “ Express bird interface technical document ” For reference ; Instant query , Refer to... In the technical documentation 4.1 or 5.1.1 part ;

5、 Logistics tracking (RequestType:1008/8008) Number of queries per day >3000 Second docking logistics tracking interface

6、 Test the subscription interface , Correct return according to the technical document indicates the successful docking of the subscription interface , Details can be found in the technical documentation .

7、 Develop push interface , nothing demo Provide , Push when pushing requestType、requestData and DataSign Three parameters , You can develop a push interface to receive these three parameters , After successful reception, the 5S Inside to express the bird to return the successful data received message , Otherwise, it will be overtime .RequestData Contains application level parameters , That is logistics trajectory ( See the technical documentation for details );

8、 Subscription interface 、 After the push interface is tested successfully , You can use the official address to subscribe to the real express number , Express birds are usually in 2-12 Push logistics information to your configured callback address within hours ;

Answer questions that may be of concern


1、 problem : Does express bird interface have concurrent requirements ?

Express bird instant query interface concurrency does not exceed 10 Time / second , Logistics tracking interface subscription no more than 30 Time / second , Electronic single interface order no more than 20 Time / second .

2、 problem : Express bird api What is the rate of charge ?

Express bird query interface and electronic bill interface are provided free of charge , If you are aging the state of data 、 There is a special need for service , Contact the express bird staff , Tailor made solutions for you , The specific charge will be determined according to your needs .

3、 problem : Express bird data update real-time how ?

Instant query interface : Get the latest trajectory information in real time , The data is consistent with the information on the official website .

Logistics tracking interface : Express bird every 2 Hours to the express company to get track of , If the order number you subscribe to does not have track update , interval 2 Hours later, I went to the express company to get the track again , Cycle in turn until there is a logistics trajectory update , Get the new track and push the queue sequence .

4、 problem : Express bird data accuracy , Will there be inaccurate logistics status ?

The accuracy of trajectory information is greater than 99.9%. Logistics track information is consistent with the official website of express company , Occasionally, the interface data provided by the express company is inconsistent with the official website , The inconsistency is less than 0.1%.

5、 problem : What is the difference between express bird instant query interface and logistics tracking interface ?

(1) Access is different :

Instant query interface , According to the express order number and express company code, real-time query logistics track information .

Logistics tracking interface , Subscriber number subscription express , Express bird system will regularly push new logistics information .

(2) The functions are different :

Instant query interface , A single request can only query the logistics information of one order , Support 10 Time /S Concurrent requests for .

Logistics tracking interface , The track of the subscription information , After launching a subscription , Express bird will continuously monitor the track information of push updates , Until you sign for it .

(3) The query quantity is different :

Real time query, daily query times <=3000 Time , Logistics tracking does not limit the number of subscriptions , And can always get the update information of each order number .

6、 problem : What is the timeliness of tracking data of express bird logistics ?

After receiving the new express bill , Will immediately join the monitoring queue , If there is a result, it will return immediately , If there is no result , Will wait for a certain time ( Such as 2 Hours ) The next monitoring . For these follow-up monitoring , If a waybill number in the express company's official website corresponding results B,B The time corresponding to the latest state is T1, Express bird will B It was sent to your company on T2, that |T2-T1| Generally in 0~2~4 Within hours , But we will continue to push you , Enable waybill status to be continuously updated .

7、 problem : Express bird logistics tracking needs us to develop our own receiving interface, right ?

Docking logistics tracking interface , You need to develop a subscription interface ( Subscribe the order number and express company code to express bird . There is a subscription interface .net,php and java edition demo, You can refer to . There is also their own development of a push interface ( Receiving express bird push logistics track ), After the development, login express bird sandbox background debugging push interface , After debugging successfully, the push interface can be self configured in the sandbox background .

8、 problem : Express bird logistics tracking push interface how to do ?

Push interface is used to receive push logistics information , Push interface is the interface we call you , You just need to receive parameters , Configure your callback address in the sandbox background ,RequestData Contains application level parameters , That is logistics trajectory , Push when pushing requestType、requestData and DataSign Three parameters ( See the technical documentation for details ), You can develop a push interface to receive these three parameters .

9、 problem : Express bird logistics tracking API What is the principle of implementation ?

How the subscription interface works is : The user subscribes the express bill number to us , We immediately join the queue and go to the official interface of the logistics company , Query track to the user push . If the data is not updated , Two hours later, I will go to the official interface of the logistics company to inquire , Push the full amount of data to users when there is new data , If the data is not updated , Repeat after two hours , Until the waybill is signed .

10、 problem : Express bird support which express logistics company query interface ?

Express bird support 600 Interface of more than three express logistics companies , Specific in express bird official website download 《 Express bird interface supports express company code .xlsx》 see .

 Express bill number query interface docking C# course .net Source code 「 Express bird API」


Express bird is a leading logistics information service provider in China , National high tech enterprise , Four rounds of financing have been completed , Has been focusing on Enterprise Logistics API Research and development of technology and opening up the information service of logistics nodes , Committed to become the world's largest logistics information hub center , At present, we support 600 The above express logistics company interface one-time docking , Provide standard logistics interface and e-commerce logistics module overall solution for enterprise users , Retail platform providers only need simple docking , It has a complete logistics service ability .
版权声明
本文为[Stillness Speaks ]所创,转载请带上原文链接,感谢
https://fheadline.com/2020/11/202011252358291405.html
相似文章

2021-08-09