/*********** typeId 请求类型* siteKey GOOGLE验证码KEY* siteReferer 当前URL**********/private static string ReCaptcha(int typeId, String siteKey, String siteReferer = ""){// 识别string authorization = "xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx";string requestUrl = "{\"captchaType\": \"ReCaptchaV2\", \"useCache\": \"true\", \"developer\": \"yyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyy\", \"siteKey\": \"" + siteKey + "\", \"siteReferer\": \"" + siteReferer + "\" }";if (typeId == 1){requestUrl = siteKey;}//jsonstring joSuccess = "";//string joResult = "";JObject jo = null;try{string jsonStr = "";if (typeId == 1){jsonStr = GetHtmlGet(requestUrl);//请求urljo = Jsons.ToJObject(jsonStr);joSuccess = jo["status"].ToString().ToLower();}else{jsonStr = GetHtmlPost(requestUrl);//请求urljo = Jsons.ToJObject(jsonStr);joSuccess = jo["taskId"].ToString().ToLower();}Console.WriteLine(joSuccess);}catch { }//识别成功if (joSuccess != ""){// 平台返回的识别结果if (typeId == 1){if (jo["status"].ToString().ToLower() == "fail"){joResult = "fail";}else if (jo["status"].ToString().ToLower() == "success"){joResult = jo["response"]["gRecaptchaResponse"].ToString();}}else{joResult = joSuccess;}Console.WriteLine(joResult);return joResult;}else{// 未知异常,一般不会出现Console.WriteLine("未知异常");}return "";}
Captcha打码注册平台注册 =》 查看
文章评论