可能是一个重复的问题。我有一个SPA并实现了我在localhost中运行的reCaptcha并给了我一个错误:“false \ nincorrect-captcha-sol”。我正在使用的代码如下所示,来自原始来源here。以前使用相同的密钥(私人和公共)工作。我可以更改或检查什么才能使其正常工作?谢谢
var httpClient = new HttpClient();
var PK = ConfigurationManager.AppSettings["recaptchaKey"];//private key
var userIP = ((HttpContextBase)this.Request.Properties["MS_HttpContext"]).Request.UserHostAddress;
var uri = "http://www.google.com/recaptcha/api/verify";
var postData = new List<KeyValuePair<string, string>>();
postData.Add(new KeyValuePair<string, string>("privatekey", PK));
postData.Add(new KeyValuePair<string, string>("remoteip", userIP));
postData.Add(new KeyValuePair<string, string>("challenge", data.Challenge));
postData.Add(new KeyValuePair<string, string>("response", data.Response));
HttpContent content = new FormUrlEncodedContent(postData);
string responseFromServer = await httpClient.PostAsync(uri, content)
.ContinueWith((postTask) => postTask.Result.EnsureSuccessStatusCode())
.ContinueWith((readTask) => readTask.Result.Content.ReadAsStringAsync().Result);
if (responseFromServer.StartsWith("true"))
{
return Contact(data);
}
答案 0 :(得分:0)
根据文档,您将发布到错误的网址 它的siteverify而不是Just in final。 https://developers.google.com/recaptcha/docs/verify