Exemplo n.º 1
0
        /// <summary>
        /// 操作步聚:获取验证码内容(从聚合API接口)
        /// </summary>
        /// <param name="base64"></param>
        /// <returns></returns>
        private string StepByGetCaptchaCodeByJUHE(QuestSourceModel model, string base64)
        {
            ShowStatusText(string.Format("{0}[登录],自动识别验证码", model.Name));

            string captchaCodeValue = string.Empty;

            if (!VerifyHelper.IsEmpty(base64))
            {
                var options = new HttpClientOptions();
                var client  = new HttpWebClientUtility();
                options.URL         = AppHelper.UrlCaptchaValJuHe;
                options.Method      = "POST";
                options.ContentType = "application/x-www-form-urlencoded";
                options.PostData    = string.Format("key={0}&codeType={1}&base64Str={2}", AppHelper.ValueJuHeKey1, AppHelper.ValueJuHeKey2, CodingHelper.UrlEncoding(base64));
                var result = client.Request(options);
                if (!VerifyHelper.IsEmpty(result.Content))
                {
                    var obj = JsonHelper.Deserialize <JObject>(result.Content);
                    if (obj != null && StringHelper.Get(obj["error_code"]) == "0")
                    {
                        captchaCodeValue = StringHelper.Get(obj["result"]);
                    }
                }
            }

            ShowStatusText(string.Format("{0}[登录],验证码识别 {1}", model.Name, !VerifyHelper.IsEmpty(captchaCodeValue) ? "成功" : "失败"));

            return(captchaCodeValue);
        }