C#网络编程高手请进
我现在想做GMAIL邮箱登陆器,但是GMAIL在登陆的时候是采用的HTTPS请求,我试了好多次都不行,我的代码是这样的:
首先的方法是获取登陆界面的表单元素的名和值,以生成请求数据:
private string GetQueryString()
{
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create( "http://mail.google.com ");
myHttpWebRequest.Method = "GET ";
myHttpWebRequest.UserAgent = @ "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; Maxthon; .NET CLR 1.1.4322; .NET CLR 2.0.50727) ";
myHttpWebRequest.Accept = "*/* ";
myHttpWebRequest.AllowAutoRedirect = false;
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
string encodingCodePage = //得到服务器响应内容的编码的编码页代码
Common.Common.GetCharsetFromResponseContentType(myHttpWebResponse.ContentType);
if (!Common.Common.IsValidCodePage(encodingCodePage)) encodingCodePage = "gb2312 ";
nextUrl = myHttpWebResponse.Headers.GetValues( "Location ")[0] ;
myHttpWebRequest = (HttpWebRequest)WebRequest.Create(nextUrl);
myHttpWebRequest.Method = "GET ";
myHttpWebRequest.UserAgent = @ "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; Maxthon; .NET CLR 1.1.4322; .NET CLR 2.0.50727) ";
myHttpWebRequest.Accept = "*/* ";
myHttpWebRequest.AllowAutoRedirect = false;
myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
nextUrl = myHttpWebResponse.Headers.GetValues( "Location ")[0];
myHttpWebRequest = (HttpWebRequest)WebRequest.Create(nextUrl);
myHttpWebRequest.Method = "GET ";