Express Bird Logistics Query interface is free to use, no restrictions, stability is also good, so interface docking to express birds for example, the user ID and key need to apply for their own http://www.kdniao.com/reg.
Using system;using system.collections.generic;using system.io;using system.linq;using System.Net;using System.Text; Using system.web;/** * * Express Bird Logistics Track Instant Query interface * * Technology QQ Group: 456320272 * @see: http://www.kdniao.com/YundanChaxunAPI.aspx * @copyrig HT: Shenzhen Fast Gold Data Technology Service CO., LTD. * * Demo e-commerce ID and private key only for testing use, formal environment please register account separately * Daily more than 500 single query volume, recommended access to our Logistics track subscription push interface */namespace test{public class K Dapisearchdemoys {//e-commerce id private string EBUSINESSID = "id required to apply to official website: http://www.kdniao.com/ServiceApply.aspx" ; E-commerce encryption private key, courier Bird provide, pay attention to safekeeping, do not leak private string AppKey = "key to apply to the official website: http://www.kdniao.com/ServiceApply.aspx"; Request URL private String requrl = "Http://api.kdniao.cc/Ebusiness/EbusinessOrderHandle.aspx"; <summary>//JSON query for order Logistics track///</summary>//<returns></returns> public string Getordertracesbyjson (string Shippercode, String expno) {string requestData = "{' Orderc Ode ': ', ' shippercode ': ' "+shippercode+" ', ' LogIsticcode ': ' "+expno+" '} "; 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 returned according to the company's business process ... return result; }///<summary>//XML Query Order Logistics track///</summary>//<returns></returns& Gt public string Getordertracesbyxml () {String requestData = "<?xml version=\" 1.0\ "encoding=\" utf-8\ " ?> "+" <Content> "+" <ordercode></ordercod E> "+ "<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 ("RequestType", "1002"); String datasign = Encrypt (RequestData, AppKey, "UTF-8"); Param. ADD ("Datasign", Httputility.urlencode (Datasign, Encoding.UTF8)); Param. ADD ("DataType", "1"); string result = Sendpost (Requrl, param); The information returned according to the company's business process ... return result; }///<summary>///Post data, return the source code of the webpage///</summary>//<param name= "url" ; Send request url</param>//<param name= "param" > Requested parameter Collection </param> <returns> response results for remote resources </returns> private string sendpost (string url, 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>//E-commerce sign signature///</summary>///<param name= "Content" > Contents </par am>///<param name= "KeyValue" >Appkey</param>///<param name= "charset" >url encoding </param& Gt <returns>datasign Signature </returns> private string Encrypt (string content, String KeyValue, String charset {if (KeyValue! = null) {return base64 (MD5 (content + KeyValue, charset), CH Arset); } return Base64 (MD5 (Content, CharSet), CharSet); }///<summary>///String MD5 encryption///</summary>///<param name= "str" > string to encrypt </p aram>///<param name= "CharSet" > Encoding </param>///<returns> redaction </returns> Priva Te 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 <) ret + = "0" + A.tostrin G ("X"); else ret + = a.tostring ("X"); } return ret. ToLower (); } catch {throw; }}///<summary>//Base64 code///</summary>/<param name= "str" > Inside </param>//<param name= "CharSet" > Encoding method </param>//<returns></returns> Private string base64 (String str, string charset) {return convert.tobase64string (System.texT.encoding.getencoding (CharSet). GetBytes (str)); } }}
aspx Interface Example
<%@ page language= "C #" autoeventwireup= "true" codebehind= "KdApiSearchYS.aspx.cs" inherits= "Test.kdapisearchys"% ><! DOCTYPE html>Aspx.cs Code
Using system;using system.collections.generic;using system.linq;using system.web;using System.Web.UI;using System.web.ui.webcontrols;namespace test{public partial class KdApiSearchYS:System.Web.UI.Page { protected void Page_Load (object sender, EventArgs e) { } protected void Button_Click (object sender, EventArgs e) { Kdapisearchdemoys search = new Kdapisearchdemoys (); string result = Search.getordertracesbyjson (This.txtShipperCode.Text.Trim (), This.txtLogisticCode.Text.Trim ()); Response.Write (Result);}}}
Express Bird Logistics Query Interface API call code example