/// <summary> /// 百度登陆判断 /// </summary> private void Login() { this.BeginInvoke(labledelegate, new object[] { labelWarning, "正在登陆百度账号..." }); BaiduLogin baiduLogin = new BaiduLogin(); //登陆 string content = baiduLogin.Login(m_loginName, m_passWord); if (BaiduLogin.m_isLogin) { BaiduLogin.m_codeString = string.Empty; BaiduLogin.m_verifyCode = string.Empty; this.BeginInvoke(labledelegate, new object[] { labelWarning, "百度账号登陆成功!" }); m_replyNum = 0; } else { int errNo = Convert.ToInt32(Regex.Match(content, m_loginErrNo).ToString()); //验证码错误 if (errNo == TieBaError.ErrNo257 || errNo == TieBaError.ErrNo6) { BaiduLogin.m_codeString = Regex.Match(content, m_loginVcodeRegex).ToString(); pictureBoxVcode1.ImageLocation = Vcode.GetLoginVcodeUrl(BaiduLogin.m_codeString); this.BeginInvoke(labledelegate, new object[] { labelWarning, "请输入登陆验证码!" }); if (thread != null) { thread.Abort(); } } //ip地址被禁 else if (errNo == TieBaError.ErrNo13) { this.BeginInvoke(labledelegate, new object[] { labelWarning, "IP地址被禁。" }); if (thread != null) { thread.Abort(); } } //重新登陆 else if (errNo == TieBaError.ErrNo2101 || errNo == TieBaError.ErrNo260005) { this.BeginInvoke(labledelegate, new object[] { labelWarning, "登陆异常,正在重新登陆..." }); //重新登陆,必须回帖数等于账号可回最大回帖数 m_replyNum = m_replyMaxNum; ChangeBaiduLogin(); } else if (errNo == TieBaError.ErrNo100023) { this.BeginInvoke(labledelegate, new object[] { labelWarning, "回帖异常,请结束回帖" }); LogManager.Instance.WriteLog(LogFileEnum.error, "异常:" + content); if (thread != null) { thread.Abort(); } } //异常 else { this.BeginInvoke(labledelegate, new object[] { labelWarning, "百度账号异常,正在更换百度账号..." }); //更新账号异常 //ClientPost.UpdateAccountAbnormal(m_loginName, errNo); LogManager.Instance.WriteLog(LogFileEnum.error, "异常:" + content); //重新登陆,必须回帖数等于账号可回最大回帖数 m_replyNum = m_replyMaxNum; ChangeBaiduLogin(); } } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; this._context = context; BaiduLogin login = new BaiduLogin(); dynamic jsonObj = null; if (Get("do") == "time") { jsonObj = login.ServerTime(); } if (Get("do") == "checkvc") { jsonObj = login.CheckVc(Post("user")); } if (Get("do") == "sendcode") { jsonObj = login.SendCode(Post("type"), Post("lstr"), Post("ltoken")); } if (Get("do") == "login") { jsonObj = login.Login(Post("time"), Post("user"), Post("pwd"), Post("p"), Post("vcode"), Post("vcodestr")); } if (Get("do") == "login2") { jsonObj = login.Login2(Post("type"), Post("lstr"), Post("ltoken"), Post("vcode")); } if (Get("do") == "getvcpic") { context.Request.ContentType = "image/jpeg"; //string imgStr = login.GetVcpic(Get("vcodestr")); //context.Response.ClearContent(); //byte[] imgBuffer = Encoding.UTF8.GetBytes(imgStr); //context.Response.BinaryWrite(imgBuffer); Image img = login.GetVcpic(Get("vcodestr")); MemoryStream ms = new MemoryStream(); img.Save(ms, System.Drawing.Imaging.ImageFormat.Png); img.Dispose(); context.Response.BinaryWrite(ms.ToArray()); context.Response.End(); } if (Get("do") == "getphone") { jsonObj = login.GetPhone(Post("phone")); } if (Get("do") == "sendsms") { jsonObj = login.SendSms(Post("phone"), Post("vcode"), Post("vcodestr"), Post("vcodesign")); } if (Get("do") == "login3") { jsonObj = login.Login3(Post("phone"), Post("smsvc")); } if (Get("do") == "getqrcode") { jsonObj = login.GetQrCode(); } if (Get("do") == "qrlogin") { jsonObj = login.QrLogin(Post("sign")); } context.Response.Write(JsonConvert.SerializeObject(jsonObj)); }