62,067
社区成员
发帖
与我相关
我的任务
分享
string url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=xxxxx&secret=xxxxx&code=&grant_type=authorization_code";
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse myRes = (HttpWebResponse)myReq.GetResponse();
Stream resStream = myRes.GetResponseStream();
StreamReader strReader = new StreamReader(resStream);
string resStr = strReader.ReadToEnd();
Response.Write(resStr);
private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{
return true; //总是接受
}
忘贴了
string url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=xxxxx&secret=xxxxx&code=&grant_type=authorization_code";
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(url);
myReq.ProtocolVersion = HttpVersion.Version10;
myReq.UserAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122 Safari/537.36";
HttpWebResponse myRes = (HttpWebResponse)myReq.GetResponse();
Stream resStream = myRes.GetResponseStream();
StreamReader strReader = new StreamReader(resStream);
string resStr = strReader.ReadToEnd();
Console.WriteLine(resStr);
Console.Read();
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;