验证recaptcha是否正确,PHP返回false
我试图验证recaptcha是否正确,但它始终为false,并且在var_转储上,recaptcha_challenge_字段和recaptcha_challenge_字段始终为null。我正在使用代码中要求的公钥: html: $resp上的var_转储给了我:验证recaptcha是否正确,PHP返回false,php,recaptcha,Php,Recaptcha,我试图验证recaptcha是否正确,但它始终为false,并且在var_转储上,recaptcha_challenge_字段和recaptcha_challenge_字段始终为null。我正在使用代码中要求的公钥: html: $resp上的var_转储给了我: object(ReCaptchaResponse)#610 (2) { ["is_valid"]=> bool(false) ["error"]=> string(21) "incorrect-captcha-sol"}
object(ReCaptchaResponse)#610 (2) { ["is_valid"]=> bool(false) ["error"]=> string(21) "incorrect-captcha-sol"}
我做错了什么?谢谢。如果有人谈到这一点,我可以先在js中序列化它,用php访问挑战和响应:
jQuery.fn.serializeObject = function(){
var o = {};
var a = this.serializeArray();
$.each(a, function() {
if (o[this.name] !== undefined) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
o[this.name] = this.value || '';
}
});
return o;
};
data = $("#myform").serializeObject();
您需要将HTML位放入表单标记中。 从:
为什么不在repatchalib.php
中使用repatcha\u get\u html
?只是在我的代码片段中显示表单的相关部分。
object(ReCaptchaResponse)#610 (2) { ["is_valid"]=> bool(false) ["error"]=> string(21) "incorrect-captcha-sol"}
jQuery.fn.serializeObject = function(){
var o = {};
var a = this.serializeArray();
$.each(a, function() {
if (o[this.name] !== undefined) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
o[this.name] = this.value || '';
}
});
return o;
};
data = $("#myform").serializeObject();
<form action="" method="post">
<script type="text/javascript"
src="http://www.google.com/recaptcha/api/challenge?k=your_public_key">
</script>
<noscript>
<iframe src="http://www.google.com/recaptcha/api/noscript?k=your_public_key"
height="300" width="500" frameborder="0"></iframe><br>
<textarea name="recaptcha_challenge_field" rows="3" cols="40">
</textarea>
<input type="hidden" name="recaptcha_response_field"
value="manual_challenge">
</noscript>
</form>