WebRequest wRequest = WebRequest.Create(url);
wRequest.Method = "Post";
wRequest.ContentType = "application/json;charset=UTF-8;";
DateTime nowtime = DateTime.Now;
string AK = "gdgshdghsdlkjhserirtieru";
wRequest.Headers.Add("NOWTIME", ToUnixTime(nowtime).ToString());//添加时间戳
string tokenEncrypt=AK + DESEncrypt(nowtime.ToString("yyyyMMddHH"), AK + nowtime.ToString("yyyyMMddHH"));//加密后的token
wRequest.Headers.Add("TOKEN",tokenEncrypt);//添加到头
wRequest.ContentLength = 0;//如果请求的接口不需要参数一定要加这句话,否则就会报"远程服务器返回错误: (411) 所需的长度 "异常..
WebResponse wResponse = wRequest.GetResponse();
Stream stream = wResponse.GetResponseStream();
StreamReader reader = new StreamReader(stream, System.Text.Encoding.UTF8);//如果返回的数据有中文,需要对应配置文件下的文件编码格式
reader.Close();
wResponse.Close();//求情关闭
string str = reader.ReadToEnd(); //url返回的值