public void TestMethodNetWorkGetList() { HttpPostHelper helper = new HttpPostHelper(); IDictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("yljgdm", "67613231-0"); string err; JContainer json; helper.PostData("http://192.168.31.180:8080/child/queryObservHz.do", dic, out json, out err); if (json == null) { Debug.WriteLine(err); } else { Debug.WriteLine(json.ToString()); } }
/// <summary> /// 获取地区列表 /// </summary> /// <returns></returns> public async Task <List <ResultCitys> > QueryCitys() { return(await Task.Run(() => { Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("channelId", channelId); string sign = MD5.Md5(HttpPostHelper.GetParamSrc(dic) + secret).ToLowerInvariant(); PostQueryCitys temp = new PostQueryCitys(); temp.channelId = channelId; temp.sign = sign; string url = $"{http}manman/index.php/open/partner/queryCitys"; string result = HttpPostHelper.DoHttpPost(url, JsonConvert.SerializeObject(temp)); ResultQueryCitys resultData = JsonConvert.DeserializeObject <ResultQueryCitys>(result); if (resultData.code == 0) { return resultData.result.cityList; } else { throw new AppException(resultData.errorMsg); } })); }
/// <summary> /// 获取当前热映影片 /// </summary> /// <returns></returns> public async Task <List <ResultFilm> > HotShowingMovies() { return(await Task.Run(() => { Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("channelId", channelId); string sign = MD5.Md5(HttpPostHelper.GetParamSrc(dic) + secret).ToLowerInvariant(); PostHotShowingMovies temp = new PostHotShowingMovies(); temp.channelId = channelId; temp.sign = sign; string url = $"{http}manman/index.php/open/partner/hotShowingMovies"; string result = HttpPostHelper.DoHttpPost(url, JsonConvert.SerializeObject(temp)); ResultHotResult resultData = JsonConvert.DeserializeObject <ResultHotResult>(result); if (resultData.code == 0) { return resultData.result.filmList; } else { throw new AppException(resultData.message); } })); }
public void TestMethodChangeState() { HttpPostHelper helper = new HttpPostHelper(); IDictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("username", "admin"); dic.Add("password", "123456"); string err; JContainer json; helper.PostData("http://192.168.31.180:8080/child/login.do", dic, out json, out err); if (json == null) { Debug.WriteLine(err); } else { Debug.WriteLine(json.ToString()); } }
public AuthenticationController(IOptions <SsoConfig> _ssoConfigs, LoginHelper _loginHelper, HttpPostHelper _httpPostHelper, SiteContext _siteContext, ComputeHashHelper _computeHashHelper) { ssoConfigs = _ssoConfigs.Value; loginHelper = _loginHelper; httpPostHelper = _httpPostHelper; siteContext = _siteContext; computeHashHelper = _computeHashHelper; }
public AuthenticationController(SiteContext _siteContext, HttpPostHelper _httpPostHelper, ComputeHashHelper _computeHashHelper) { siteContext = _siteContext; httpPostHelper = _httpPostHelper; computeHashHelper = _computeHashHelper; }
internal bool GetAntiRobot() { string qwantCaptchaId = string.Empty; string ruCaptchaId = string.Empty; string url = "https://api.qwant.com/api/anti_robot/get"; string response = HttpGetHelper.HttpGet(url); QwantAntiRobotResponse result = JsonConvert.DeserializeObject <QwantAntiRobotResponse>(response); if (result.status == "success") { qwantCaptchaId = result.data.id; /* sample code for saving captcha image * * * string base64str = result.data.img.Split(',')[1]; * byte[] bytes = Convert.FromBase64String(base64str); * * Image image; * using (MemoryStream ms = new MemoryStream(bytes)) * { * image = Image.FromStream(ms); * } * * Bitmap img = new Bitmap(image); * img.Save($"{outputPath}\\antiRobot.png");*/ var parameters = new Dictionary <string, string>() { { "coordinatescaptcha", "1" }, { "method", "base64" }, { "key", this.options.ruCaptchaApiKey }, { "body", result.data.img }, { "json", "1" }, { "textinstructions", "Найдите фигуру, отличающуюся от остальных" } }; bool bResult = false; var postResult = HttpPostHelper.PostRequest(RuCaptchaApi.ruCaptchaInUrl, parameters, out bResult); if (bResult) { bResult = false; var captchaInResult = JsonConvert.DeserializeObject <RuCaptchaApi.RuCaptchaResponse>(postResult); if (captchaInResult.status != "1") { logger.Warn($"RuCaptcha/in.php post request error {captchaInResult.request}"); } else { // captcha post request successfull, try get result ruCaptchaId = captchaInResult.request; bool captchaRecognized = false; int errorsCount = 0; do { Thread.Sleep(5000); string resQuery = string.Format(RuCaptchaApi.ruCaptchaResUrl, this.options.ruCaptchaApiKey, "get", ruCaptchaId ); response = HttpGetHelper.HttpGet(resQuery); RuCaptchaApi.RuCaptchaBasicResponse captchaGetResult; try { captchaGetResult = JsonConvert.DeserializeObject <RuCaptchaApi.RuCaptchaResponse>(response); captchaRecognized = captchaGetResult.status == "1"; if (!captchaRecognized) { logger.Warn($"RuCaptcha/res.php get result error {(captchaGetResult as RuCaptchaApi.RuCaptchaResponse).request}"); errorsCount++; } } catch (Exception ex) { captchaGetResult = JsonConvert.DeserializeObject <RuCaptchaApi.RuClickCaptchaResponse>(response); captchaRecognized = captchaGetResult.status == "1"; if (!captchaRecognized) { logger.Warn($"RuCaptcha/res.php get result unknown error"); errorsCount++; } } if (captchaRecognized) { var captchaCoordinatesResult = JsonConvert.DeserializeObject <RuCaptchaApi.RuClickCaptchaResponse>(response); //var coordinates = captchaCoordinatesResult.request[0]; // send results to QwantApi bResult = this.ResolveAntiRobot(qwantCaptchaId, ruCaptchaId, captchaCoordinatesResult.request); } Thread.Sleep(5000); }while (!captchaRecognized && (errorsCount < 10)); } } return(bResult); } return(false); }