public string BuildQuery(ExpressEntity entity) { var param = new Dictionary <string, string>(); param.Add("type", "auto"); //快递公司缩写,自动识别请写auto param.Add("number", entity.ExpressNo); //需要查询的订单号 return(BuildQuery(param, "utf-8")); }
public string BuildQuery(ExpressEntity entity) { var param = new Dictionary <string, string>(); param.Add("com", ConvertCompany(entity.Company)); //需要查询的快递公司编号 param.Add("no", entity.ExpressNo); //需要查询的订单号 param.Add("key", appcode); //你申请的key param.Add("dtype", ""); //返回数据的格式,xml或json,默认json return(BuildQuery(param, "utf-8")); }
public string ExpressQuery(ExpressEntity entity) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(QueryUrl + "?" + BuildQuery(entity)); //GET请求 request.Method = "GET"; request.ReadWriteTimeout = 5000; request.ContentType = "text/html;charset=UTF-8"; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream myResponseStream = response.GetResponseStream(); StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8")); //返回内容 string retString = myStreamReader.ReadToEnd(); return(retString); }
public string ExpressQuery(ExpressEntity entity) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(QueryUrl + "?" + BuildQuery(entity)); //GET请求 request.Method = "GET"; request.ReadWriteTimeout = 5000; request.ContentType = "text/html;charset=UTF-8"; Dictionary <string, string> header = new Dictionary <string, string>(); header.Add("authoration", "apicode"); header.Add("apicode", appcode); BuildHeader(header, request); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream myResponseStream = response.GetResponseStream(); StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8")); //返回内容 string retString = myStreamReader.ReadToEnd(); return(retString); }