Exemple #1
0
        public void VerifycodeClient()
        {
            CheckRegmasterClient checkRegmasterClient = new CheckRegmasterClient();
            var checkRegmasterRes = checkRegmasterClient.Send(new RegmasterReq {
                QQ = "515404"
            });
            VerifycodeClient verifycodeClient = new VerifycodeClient();

            verifycodeClient.GetVerifyCodeImage(new VerifyCodeReq {
                UID = "515404", Cap_cd = checkRegmasterRes.Verifysession
            });
            verifycodeClient.Verify(new VerifyCodeReq {
                UID = "515404", Cap_cd = checkRegmasterRes.Verifysession, VerifyCode = ""
            });
        }
Exemple #2
0
        public LoginAck Login(string qq, string pass, string verifyCode = "")
        {
            if (_CheckRegmasterClient == null)
            {
                _CheckRegmasterClient = new CheckRegmasterClient();
            }

            if (_VerifycodeClient == null)
            {
                _VerifycodeClient = new VerifycodeClient();
            }
            Status = LoginStatus.Logging;
            if (_QQ != qq)
            {
                WaitUserInputVerifyCode = false;
            }
            if (!WaitUserInputVerifyCode)
            {
                _QQ           = qq;
                _RegmasterRes = _CheckRegmasterClient.Send(new RegmasterReq {
                    QQ = qq
                });

                if (_RegmasterRes.MustHaveVerifycode)
                {
                    var image = _VerifycodeClient.GetVerifyCodeImage(new VerifyCodeReq {
                        UID = qq, Cap_cd = _RegmasterRes.Verifysession
                    });
                    if (VerifyCodeImageLoad != null)
                    {
                        VerifyCodeImageLoad(image);
                    }
                    WaitUserInputVerifyCode = true;
                    Status = LoginStatus.Logoff;
                    return(new LoginAck {
                        LoginStatus = Status, ErrorMessage = "please input the verifyCode."
                    });
                }
            }

            if (WaitUserInputVerifyCode)
            {
                if (string.IsNullOrEmpty(verifyCode))
                {
                    Status = LoginStatus.Logoff;
                    return(new LoginAck {
                        LoginStatus = Status, ErrorMessage = "please check your verifyCode."
                    });
                }
                var res = _VerifycodeClient.Verify(new VerifyCodeReq {
                    UID = qq, Cap_cd = _RegmasterRes.Verifysession, VerifyCode = verifyCode
                });
                _RegmasterRes.Verifycode    = res.Randstr;
                _RegmasterRes.Verifysession = res.Ticket;
                WaitUserInputVerifyCode     = false;
                if (res.Randstr.Length != 4)
                {
                    VerifyCodeReLoad();
                    WaitUserInputVerifyCode = true;
                    Status = LoginStatus.Logoff;
                    return(new LoginAck {
                        LoginStatus = Status, ErrorMessage = "error verifyCode. try again"
                    });
                }
            }

            if (_LoginClient == null)
            {
                _LoginClient = new LoginClient();
            }

            var loginRes = _LoginClient.Send(new LoginReq {
                QQ = qq, Pass = pass, Regmaster = _RegmasterRes,
            });

            if (loginRes.IsLogin)
            {
                LoginedQQ        = new LoginedQQ();
                LoginedQQ.QQ     = qq;
                LoginedQQ.Cookie = loginRes.SetCookies.ToCookieList();
                FileHelper.SaveFile(LoginedQQ.SerializeObject());
                Status = LoginStatus.Logged;
                return(new LoginAck {
                    LoginStatus = Status, ErrorMessage = ""
                });
            }
            Status = LoginStatus.Logoff;
            return(new LoginAck {
                LoginStatus = Status, ErrorMessage = "check your name or password."
            });
        }