文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>【C#源码】Discuz论坛登录源码

【C#源码】Discuz论坛登录源码

时间:2010-10-12  来源:bigfun4000

/// /// 登陆Discuz论坛 文章来源:酷趣网 /// /// 登陆后返回的cookie public CookieContainer login(string usrname, string paw, string login_url) { #region 初始化登陆信息 文章来源:酷趣网 string strId = usrname; string strPassword = paw; string loginsubmit = "true"; string formhash = "10405a6f"; string cookietime = "315360000"; CookieContainer cc = new CookieContainer(); ASCIIEncoding encoding = new ASCIIEncoding(); string postData = "&loginsubmit=" + loginsubmit + "&formhash=" + formhash + "&cookietime=" + cookietime + "&loginfield=username&username=" + strId + "&password=" + strPassword; byte[] data = Encoding.UTF8.GetBytes(postData); #endregion try { // Prepare web request 文章来源:酷趣网 HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(new Uri(login_url)); myRequest.CookieContainer = cc; myRequest.Method = "POST"; myRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"; myRequest.ContentType = "application/x-www-form-urlencoded"; myRequest.ContentLength = data.Length; Stream newStream = myRequest.GetRequestStream(); // Send the data. newStream.Write(data, 0, data.Length); newStream.Close(); // Get response 文章来源:酷趣网 HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse(); StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.GetEncoding("gbk")); StringBuilder builder = new StringBuilder(); string tempPath = reader.ReadToEnd(); reader.Close(); myResponse.Close(); } catch (WebException webEx) { return null; } return cc; //返回cookie 文章来源:酷趣网 }

相关阅读 更多 +
排行榜 更多 +
无限奇兵降临国际服

无限奇兵降临国际服

策略塔防 下载
奇妙料理餐厅小游戏

奇妙料理餐厅小游戏

模拟经营 下载
以太地牢中文

以太地牢中文

冒险解谜 下载