コード例 #1
0
        public virtual string Login(string verifyCode)
        {
            if (IsNeedVerifyCode)
            {
                if (!CheckValCode(verifyCode))
                {
                    return("验证码输入错误");
                }
            }
            string res         = string.Empty;
            var    pemToXml    = RSAHelper.PemToXml(pubksy);
            var    password    = RSAHelper.RSAEncrypt(pemToXml, this.password);
            var    httpContent = new FormUrlEncodedContent(new Dictionary <string, string>()
            {
                { "staticpage", staticpage },
                { "charset", charset },
                { "token", token },
                { "tpl", TPL },
                { "subpro", "" },
                { "apiver", "v3" },
                { "tt", HttpUtil.GetTimeStamp() },
                { "codestring", verifyStr },
                { "safeflg", "0" },
                { "u", u },
                { "isPhone", "false" },
                { "detect", "1" },
                { "quick_user", "0" },
                { "gid", gid },
                { "logintype", "dialogLogin" },
                { "logLoginType", "pc_loginDialog" },
                { "idc", "" },
                { "loginmerge", "true" },
                { "splogin", "rate" },
                { "username", userName },
                { "password", password },
                { "verifycode", valcode },
                { "mem_pass", "on" },
                { "rsakey", rsakey },
                { "crypttype", "12" },
                { "ppui_logintime", HttpUtil.Generateplogintime() },
                { "countrycode", "" },
                { "fp_uid", string.IsNullOrEmpty(GetCookieValue("FP_UID"))?"a8e078358d61a058b43420dee15e9e77":GetCookieValue("FP_UID") },
                //{"fp_info", "960338120bd__cbs__"+HttpUtil.GenerateCallBack()+"8b87eb0671ea3df2d002~~~nxnn3QqCEgie0x2_Unn6yqz090gtoCdtRC_qqz090gtoCd0RC_unmCsVnmCsJnnsEnm3pOq0xwEgi~JIJH4zEp4gVkJAVkFnERaUirBniP4~LPJoEWJ9HdXAFiBzieJAt~4Au~6IskJI2eJnTWcutK4gtOBgugJGJW6ItK8UsianJW6ItKanTw7AE-czFW4mTpXobP4AEYF3JAXAEdJI2M4AwQJzbNJnBRJzHq6UswJAhQ4gJPXnhiJzBHJAwQ6A~W9zukXIJiYgTHJAVk8zieBnE-4zuWcAVw6grNanTLJgiec3tKazhNJEs3FiJHJIBiaRHH4UFiazVw4mLrJn6NBziiBgE-vUnsBqC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ASRkZGRDQIAHpGRmZuC1pfZnsyNwJ_AkMOTzP3Nks293K_cq8S20g0CACaRkZmcvemo5qHzsv-g_6_8rPPC8q3yhOGT-pzlpsmtyIvjguyL7gkCADWws87Pu7u7u7uwbWxvBgdgYERESx9eEFcFRAlWCVkKWgU0BFsEchdlDGoTUD9bPn0VdBp9GAcCAASRkZGRCQIAJ4qIU1I_Pz8_PzDW1oLDjcqY2ZTLlMSXx5ipmcaZ74r4kfeOzaLGowwCACKKnp6enozpvfyy9afmq_Sr-6j4p5am-abQtceuyLHynfmcDAIAIopvb29vfCp-P3E2ZCVoN2g4aztkVWU6ZRN2BG0LcjFeOl8HAgAEkZGRkQkCACOGhcDBDAwMDAwTubntrOKl97b7pPur-Kj3xvap9oXwkv-W4g"},
                { "callback", "parent.bd__pcbs__" + HttpUtil.GenerateCallBack() },
            });

            httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");
            //httpClient.DefaultRequestHeaders.Clear();
            //httpClient.DefaultRequestHeaders.Add("Accept-Language", "zh-CN,zh;q=0.8");
            //httpClient.DefaultRequestHeaders.Add("user-agent", "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)");a
            HttpResponseMessage response = httpClient.PostAsync(new Uri(loginPostURL), httpContent).Result;

            response.EnsureSuccessStatusCode();
            String result = response.Content.ReadAsStringAsync().Result;

            if (response.StatusCode.Equals(HttpStatusCode.OK))
            {
                //var cookies = HttpHelper.GetAllCookies(cookieContainer);
                //return HttpHelper.GetAllCookies(cookieContainer).FirstOrDefault(c => c.Name.Equals("BDUSS")) != null;
                int    i1    = result.IndexOf("err_no=");
                int    i2    = result.IndexOf("&callback=");
                string errno = result.Substring(i1, i2 - i1).Replace("err_no=", "");
                switch (errno)
                {
                case "-1":
                    res = "系统错误,请您稍后再试";
                    break;

                case "2":
                    res = "您输入的帐号不存在";
                    break;

                case "4":
                    res = "您输入的帐号或密码有误 field : password";
                    break;

                case "6":
                    res = "您输入的验证码有误 field : verifyCode";
                    break;

                case "7":
                    res = "密码错误";
                    break;

                case "257":
                    res = "需要填入验证码";
                    break;

                default:
                    res = "errno:" + errno;
                    break;
                }
            }
            //httpClient.Dispose();
            return(res);
        }
コード例 #2
0
 public string GetCookieValue(string cookieName)
 {
     return(HttpUtil.GetCookieValue(httpClientHandler.CookieContainer, cookieName));
 }