public string Query(string queryString) { HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(RequestURL); request.Method = "POST"; UTF8Encoding encoding = new UTF8Encoding(); byte[] byteArray = encoding.GetBytes(queryString); request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = byteArray.Length; Stream requestStream = request.GetRequestStream(); requestStream.Write(byteArray, 0, byteArray.Length); WebResponse response = request.GetResponse(); Stream responseStream = response.GetResponseStream(); StreamReader sr = new StreamReader(responseStream); string result = sr.ReadToEnd(); requestStream.Close(); sr.Close(); responseStream.Close(); return result; }
时间: 2024-11-16 08:40:25