public static string Login(string qq, string password, string vfCode) { vfCode = vfCode.ToUpper(); StringBuilder sb = new StringBuilder(100); sb.Append("https://ssl.ptlogin2.qq.com/login?u="); sb.Append(qq); sb.AppendFormat("&p={0}", PasswordEncrypt.MD5QQEncrypt(long.Parse(qq), password, vfCode)); sb.AppendFormat("&verifycode={0}", vfCode); sb.Append(HttpText.LoginChar); return(sb.ToString()); }
/// <summary> /// QQ登录. /// </summary> /// <param name="qqNumber">QQ号码</param> /// <param name="password">QQ密码.</param> /// <param name="verifyCode">QQ的验证码.</param> /// <param name="status">QQ登录的状态.</param> /// <returns></returns> public LoginResult Login(string qqNumber, string password, string verifyCode) { if (!Tool.CheckQQNumber(qqNumber)) { return(LoginResult.QQNumberError); } if (!Tool.CheckQQPassword(password)) { return(LoginResult.PasswordError); } verifyCode = verifyCode.ToUpper(); StringBuilder sb = new StringBuilder(100); sb.Append("https://ssl.ptlogin2.qq.com/login?u="); sb.Append(qqNumber); sb.AppendFormat("&p={0}", PasswordEncrypt.MD5QQEncrypt(long.Parse(qqNumber), password, verifyCode)); sb.AppendFormat("&verifycode={0}", verifyCode); sb.Append(HttpText.LoginChar); string url = sb.ToString(); //web.SetReferer(HttpText.LoginReferer); //string text = web.HttpSendData(url); _HttpWeb.Referer = HttpText.LoginReferer; //发送登录请求. string text = _HttpWeb.SendToText(url); if (text.IndexOf("登录成功") > 0) { GetNickName(text); //模拟重定向. text = _HttpWeb.SendToText(GetDirectionUrl(text)); if (text.Length > 0) { _HttpWeb.SendToText("http://d.web2.qq.com//loginproxy.html?login2qq=1&webqq_type=10"); } //进行第二次的登录. sb.Clear(); string ptwebqq = GetKey(); sb.Append("r=%7B%22status%22%3A%22online%22%2C%22ptwebqq%22%3A%22"); sb.Append(ptwebqq); sb.Append("%22%2C%22passwd_sig%22%3A%22%22%2C%22clientid%22%3A%22"); sb.AppendFormat("{0}%22%2C%22psessionid%22%3A%22null%22%7D&clientid={0}&psessionid=null", _ClientID); _HttpWeb.Referer = HttpText.Login2Referer; text = _HttpWeb.PostWebRequest("http://d.web2.qq.com/channel/login2", sb.ToString(), Encoding.UTF8); if (GetLoginToken(text)) { //启动消息监听. Task tast = new Task(() => { ListenMessage(); }); tast.Start(); _MyQQNumber = qqNumber; return(LoginResult.LoginSucceed); } } else if (text.IndexOf("验证码") > -1) { return(LoginResult.VerifyCodeError); } else if (text.IndexOf("密码") > -1) { return(LoginResult.PasswordError); } else if (text.IndexOf("您的帐号暂时无法登录") > -1) { return(LoginResult.QQNumberError); } //检查登录结果. return(LoginResult.LoginFail); }