private static string GetContentByAPI(LogisticsTools logisticsTools, string key, string computer, string expressNo) { HttpWebResponse response; if (logisticsTools == LogisticsTools.Kuaidiniao) { return(ExpressTrackingSetService.GetHiShopExpTrackInfo(FormatCompanyCodeByKuaidi100Code(computer), expressNo)); } string str = ""; HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://api.kuaidi100.com/api?id=" + key + "&com=" + computer + "&nu=" + expressNo); request.Timeout = 0x1f40; try { response = (HttpWebResponse)request.GetResponse(); } catch { return(str); } if (response.StatusCode == HttpStatusCode.OK) { StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding("UTF-8")); str = reader.ReadToEnd().Replace("&", "").Replace(" ", "").Replace("&", ""); } return(str); }
private static string GetContentByAPI(LogisticsTools logisticsTools, string key, string computer, string expressNo) { string result; if (logisticsTools == LogisticsTools.Kuaidiniao) { result = ExpressTrackingSetService.GetHiShopExpTrackInfo(ExpressHelper.FormatCompanyCodeByKuaidi100Code(computer), expressNo); } else { string text = ""; HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(string.Concat(new string[] { "http://api.kuaidi100.com/api?id=", key, "&com=", computer, "&nu=", expressNo })); httpWebRequest.Timeout = 8000; HttpWebResponse httpWebResponse; try { httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse(); } catch { result = text; return(result); } if (httpWebResponse.StatusCode == HttpStatusCode.OK) { Stream responseStream = httpWebResponse.GetResponseStream(); StreamReader streamReader = new StreamReader(responseStream, Encoding.GetEncoding("UTF-8")); text = streamReader.ReadToEnd(); text = text.Replace("&", ""); text = text.Replace(" ", ""); text = text.Replace("&", ""); } result = text; } return(result); }