- /// <summary>
- /// 返回JSon数据
- /// </summary>
- /// <param name="JSONData">要处理的JSON数据</param>
- /// <param name="Url">要提交的URL</param>
- /// <returns>返回的JSON处理字符串</returns>
- public string GetResponseData(string JSONData,string Url)
- {byte[] bytes = Encoding.UTF8.GetBytes(JSONData)
- HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
- request.Method = "POST";
- request.ContentLength = bytes.Length;
- request.ContentType = "text/xml";
- Stream reqstream = request.GetRequestStream();
- reqstream.Write(bytes, 0, bytes.Length);
- //声明一个HttpWebRequest请求
- request.Timeout = 90000;
- //设置连接超时时间
- request.Headers.Set("Pragma", "no-cache");
- HttpWebResponse response = (HttpWebResponse)request.GetResponse();
- Stream streamReceive = response.GetResponseStream();
- Encoding encoding = Encoding.UTF8;
- StreamReader streamReader = new StreamReader(streamReceive, encoding);
- string strResult = streamReader.ReadToEnd();
- streamReceive.Dispose();
- streamReader.Dispose();
- return strResult;
- }
//string serviceAddress = "https://www.culturesclub.com/CultureHomes/api/CSMemberValidation";
//HttpWebRequest request = (HttpWebRequest)WebRequest.Create(serviceAddress);
//request.Method = "POST";
//request.ContentType = "application/json";
//string strContent = @"{ ""client_token"": ""89e"",""member"": ""0101943""}";
//using (StreamWriter dataStream = new StreamWriter(request.GetRequestStream()))
//{
// dataStream.Write(strContent);
// dataStream.Close();
//}
//HttpWebResponse response = (HttpWebResponse)request.GetResponse();
//string encoding = response.ContentEncoding;
//if (encoding == null || encoding.Length < 1)
//{
// encoding = "UTF-8"; //默认编码
//}
//StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(encoding));
//string retString = reader.ReadToEnd();
////解析josn
//JObject jo = JObject.Parse(retString);
//textBox1.Text = jo.ToString();