National Express popular third-party logistics Tracking Number api docking

  • At the same time hundreds of millions of Internet users to express the birds provide express delivery of information services, B2B and other networks also provide a platform for the free Open API interface, and enterprise-class courier tracking services to help companies, electricity providers improve the user experience and the level of management of the logistics chain. To create a barrier-free between the user and the courier brand communication channel
  • Now supports domestic and international courier company api 418 common query interface
  • Description: by sending a request to the specified address, to return with comprehensive results as JSON, XML and other formats

1, application scenarios

Calling this API to display results (1) Electric's Web site user opens the "My Orders"

(2) logistics systems call this API to check a consignment before all states to sign reconciliation

2, the need for authorization

Yes,

Before docking to go:

Please  express Birds single query API application address  application

3. Go to "My Member" real-name authentication
Note:
3.1, authentication type, application type can be selected according to the actual situation, the interface returns the data has nothing to do with the selection result;
3.2 marked * are required, clear requirements to upload , jpg format pictures and less than 2M of documents;
3.3, an information technology docking Intelligence user side docking engineer;
3.4, any additional questions can be added into the official website of the business cooperation group for consultation.
After successful authentication, enter the "Services Management", subscribe to a membership service

Request Address: http://www.kdniao.com/api-track

 

demo examples:

the using the System;
 the using the System.Collections.Generic;
 the using the System.Linq;
 the using the System.Text;
 the using the System.Web;
 the using the System.Net;
 the using the System.IO; 
  
namespace KdGoldAPI 
{ 
    public  class KdApiSearchDemo 
    { 
        // electricity supplier ID 
        Private  String EBusinessID = " 1237100 " ;
         // electricity providers private key encryption, providing courier birds, take good care not to leak 
        Private  String AppKey = " 518a73d8-1f7f-441a-b644-33e77b49d846 " ;
        //请求url
        private string ReqURL = "http://api.kdniao.cc/Ebusiness/EbusinessOrderHandle.aspx";
 
        /// <summary>
        /// Json方式 查询订单物流轨迹
        /// </summary>
        /// <returns></returns>
        public string getOrderTracesByJson()
        {
            string requestData = "{'OrderCode':'','ShipperCode':'SF','LogisticCode':'589707398027'}";
 
            Dictionary<string, string> param = new Dictionary<string, string>();
            param.Add("RequestData", HttpUtility.UrlEncode(requestData, Encoding.UTF8));
            param.Add("EBusinessID", EBusinessID);
            param.Add("RequestType", "1002");
            string dataSign = encrypt(requestData, AppKey, "UTF-8");
            param.Add("DataSign", HttpUtility.UrlEncode(dataSign, Encoding.UTF8));
            param.Add("DataType" , " 2 " ); 
 
            String Result = sendPost (reqURL, param); 
 
            // The information processing business ...... returned 
 
            return Result; 
        } 
 
        ///  <Summary> 
        /// the XML Query manner stream line locus
         ///  </ Summary> 
        ///  <Returns> </ Returns> 
        public  String getOrderTracesByXml () 
        { 
            String requestData = " <? XML Version = \" 1.0 \ "encoding = \" UTF-. 8 \ "?> " +
                                 " <Content> " +
                                "<OrderCode></OrderCode>" +
                                "<ShipperCode>SF</ShipperCode>" +
                                "<LogisticCode>589707398027</LogisticCode>" +
                                "</Content>";
 
            Dictionary<string, string> param = new Dictionary<string, string>();
            param.Add("RequestData", HttpUtility.UrlEncode(requestData, Encoding.UTF8));
            param.Add(" EBusinessID " , EBusinessID); 
            param.Add ( " the RequestType " , " 1002 " );
             String dataSign = the encrypt (requestData, the AppKey, " UTF-. 8 " ); 
            param.Add ( " DataSign " , HttpUtility.UrlEncode (dataSign, Encoding.UTF8)); 
            param.Add ( " the DataType " , " . 1 " ); 
 
            String Result = sendPost (reqURL, param); 
 
            // returned by the business process information ......
 
            returnResult; 
        } 
 
        ///  <Summary> 
        /// submitted Post mode data, return to the page source code
         ///  </ Summary> 
        ///  <param name = "URL"> the URL request transmitted </ param> 
        // /  <name = "param" param> parameter set requested </ param> 
        ///  <Returns> in response to the result of the remote resource </ Returns> 
        Private  String sendPost ( String URL, the Dictionary < String , String > param) 
        { 
            String result = "" ;
            StringBuilder postData = new StringBuilder();
            if (param != null && param.Count > 0)
            {
                foreach (var p in param)
                {
                    if (postData.Length > 0)
                    {
                        postData.Append("&");
                    }
                    postData.Append(p.Key);
                    postData.Append("=");
                    postData.Append(p.Value);
                }
            }
            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.Message;
            }
            return result;
        }
 
        ///<summary>
        ///电商Sign签名
        ///</summary>
        ///<param name="content">内容</param>
        ///<param name="keyValue">Appkey</param>
        ///<param name="charset">URL编码 </param>
        ///<returns>DataSign签名</returns>
        private string encrypt(String content, String keyValue, String charset)
        {
            if (keyValue != null)
            {
                return base64(MD5(content + keyValue, charset), charset);
            }
            returnBase64 (MD5 (Content, charset), charset); 
        } 
 
        /// 
            {<Summary> 
        /// string the MD5
         /// </ Summary> 
        /// <param name = "STR"> be encrypted string </ param> 
        /// <param name = "charset"> encoding </ param> 
        /// <Returns> ciphertext </ Returns> 
        Private  String the MD5 ( String STR, String charset) 
        { 
            byte [] = Buffer System.Text.Encoding.GetEncoding (charset) .GetBytes (STR);
             the try 
                the System Check .Security.Cryptography.MD5CryptoServiceProvider; 
                Check = new 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));
        }
    }
}

 

Guess you like

Origin www.cnblogs.com/kdn2019/p/11579809.html
Recommended