Tact surface of the electronic account provisioning single application process (Bird Express example)

 

Electronic single surface by:

5.3.1 , you need real-name authentication prior request interface, subscribe to a membership service, otherwise it will fail the request and returns the prompt "did not subscribe to the interface";

5.3.2 , interface development need to download the " Express birds Interface Technical Documentation ", " 2018 Bird Express interface support Express coded list .xlsx ", " Express e-birds face a single customer number parameter table ," " express courier company type of business " view; electronic single plane, with reference to section 3.2 of the technical documentation;

5.3.3 , birds Express official website - help download the document " e-side single Demo " reference is (provides .NET, Java, demo PHP three languages only); users of other language development needs to download technical documentation developed;

5.3.4 , the use of electronic interfaces also need to face a single electronic surface single account ( Note: Different faces every single electronic courier companies need to transfer the account field, please refer to " express the birds face a single electronic customer number parameter table ");

       5.3.4.1 , the test environment: you must use the test account Express offers a bird, a bird in the courier official website - help download the document " Express birds face a single electronic customer number parameter table " to view the account interface requests and corresponding field names, in addition to electronic surface single interface testing environment is maintained by the courier company, courier companies often adjust instability and even lead to a test environment is not available, such as: Shen Tong, home delivery, security can be. Formal environment can be normal use. Test environment is only available to users through the transfer interface, the same birds each express delivery company support logic, measured through a courier company description has been transferred through the interface .

 5.3.4.2, formal environment:

² without having to face a single account electronic orders directly:

SF, EMS (Guangdong Province issued the country), home delivery, postal express parcels, China Railway Express, China Post standard fast, all of a courier;

² Online (the official website of the courier birds background) application account:

Excellent speed, rhyme, tact, as far Express, security can, BES;

(Application Path: Bird Express official website - Electronic single face - my courier company - apply for a new courier company);

² other courier company and you need to apply for an account (pre-existing order number) at the local courier network lines can be used.

 

Electronic side single batch printing:

5.3.5 , birds Express official website - help download the document " electronic single batch printing surface Demo " reference is (provides .NET, Java, demo PHP three languages only); users of other language development needs to download technical documentation developed ;

5.3.6 docking Notes

5.3.6.1, ensure that the interface in the electricity supplier ID, keys (AppKey) and user management background merchant ID, keys exactly the same;

5.3.6.2, OrderCode must be single single single interface to express a formal environmental surfaces birds electronic order number; PortName is the printer name, must be local

The same printer name;

5.3.6.3, ensure that the interface demo in GetIp () method to get users to connect to the IP and printer computer IP (Baidu search IP138) consistent.

5.3.7 , install Express bird print controls C-Lodop (Print)

Installation 1, call the courier birds batch print will be prompted to download the demo.

Installation 2, a bird in the courier official website to download, download address: http://www.kdniao.com/product-eorder-specific

 demo examples:

the System the using; 
the using the System.Collections.Generic; 
the using the System.IO; 
the using the System.Linq; 
the using the System.Net; 
the using the System.Text; 
the using the System.Web; 

namespace KdGoldAPI 
{ 
    / ** 
    * 
    * Birds electronic delivery side single Interface 
    * 
* @ technology QQ 
    * @ technology QQ group 
    * @see : http://www.kdniao.com/MiandanAPI.aspx 
    * @copyright: Shenzhen City Express gold data services Limited 
    * 
    * Key ID and go to the official website application: HTTP : //www.kdniao.com/ServiceApply.aspx 
    * / 
    public  class KdApiEOrderDemo 
    { 
        // electricity supplier ID 
        Privatestring EBusinessID = "Courier birds go to the official website application http://www.kdniao.com/ServiceApply.aspx" ;
         // electricity providers private key encryption, providing courier birds, take good care not to leak 
        Private String AppKey = "Courier go Bird official website application http://www.kdniao.com/ServiceApply.aspx " ;
         // request url, address a formal environment: http://api.kdniao.cc/api/Eorderservice 
        Private String reqURL =" HTTP: // TestAPI .kdniao.cc: 8081 / API / EOrderService " ; 

        // / <Summary> 
        // / Json single surface of the electronic 
        // / </ Summary> 
        // / <Returns> </ Returns> 
        public String orderTracesSubByJson () 
        { 
            String requestData = "{ 'OrderCode': '012657700312'," +
                                  " 'ShipperCode': 'YTO'," +
                                  "{" +
                                  " 'PayType':. 1," + 
                                  " 'ExpType':. 1," + 
                                  " 'Cost': 1.0," + 
                                  " 'OtherCost': 1.0," + 
                                  " 'Sender':" + 
                                  "{" + 
                                  " 'Company ':' LV ',' Name ':' Taylor ',' Mobile ':' 1xxxxxxxxxx ',' provinceName ':' Shanghai ',' CityName ':' Shanghai ',' ExpAreaName ':' Qingpu District ',' Address' : 'Pearl Road No. 73 is'}, "+ 
                                  " "Receiver": "+ 
                                  " 'Company': 'GCCUI', 'the Name': 'Yann', 'Mobile': '1xxxxxxxxxx', 'provinceName': 'Beijing', 'CityName': 'Beijing', 'ExpAreaName': 'Chaoyang' , 'Address': 'Sanlitun street Masahide building'}, "+ 
                                  " 'Commodity': "+ 
                                  " [{ "+ 
                                  " 'GoodsName': 'shoe', 'Goodsquantity': 1, 'GoodsWeight': 1.0}], " + 
                                  " 'the AddService':" + 
                                  "[{" + 
                                  " 'the Name': 'of COD', 'the Value': '1020.'}],"+
                                  "'Weight':1.0," +
                                  "'Quantity':1," +
                                  "'Volume':0.0," +
                                  "'Remark':'小心轻放'," +
                                  "'IsReturnPrintTemplate':1}";

            Dictionary<string, string> param = new Dictionary<string, string>();
            param.Add("RequestData", HttpUtility.UrlEncode(requestData, Encoding.UTF8));
            param.Add("EBusinessID", EBusinessID);
            param.Add("RequestType", "1007");
            string dataSign = encrypt(requestData, AppKey, "UTF-8");
            param.Add("DataSign", HttpUtility.UrlEncode(dataSign, Encoding.UTF8));
            param.Add("The DataType", "2" ); 

            String Result = sendPost (reqURL, param); 

            // The business process information returned ...... 

            return Result; 
        } 

        // / <Summary>
        // / Post embodiment submit data, return to the page source code 
        // / </ Summary> 
        @ / <param name = "URL"> send the URL request </ param> 
        @ / <param name = "param"> the requested set of parameters </ param> 
        // / <Returns> in response to the result of the remote resource </ Returns> 
        Private String sendPost (String URL, the Dictionary <String, String> param) 
        { 
            String result = "" ; 
            the StringBuilder postData = new new the 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>
        privateString the encrypt (String Content, String the keyValue, String charset) 
        { 
            IF (! the keyValue = null ) 
            { 
                return Base64 (the MD5 (Content + the keyValue, charset), charset); 
            } 
            return[] buffer =Base64 (MD5 (Content, charset), charset); 
        } 

        // / <Summary> 
        // / MD5 encryption string 
        // / </ Summary> 
        // / <param name = "STR"> be encrypted string < / param> 
        // / <param name = "charset"> coding </ param> 
        // / <Returns> ciphertext </ Returns> 
        Private String the MD5 (STR String, String charset) 
        { 
            byte System.Text.Encoding. the GetEncoding (charset) .GetBytes (STR);
             the try 
            { 
                System.Security.Cryptography.MD5CryptoServiceProvider Check; 
                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/11607850.html