Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/227.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
验证recaptcha是否正确,PHP返回false_Php_Recaptcha - Fatal编程技术网

验证recaptcha是否正确,PHP返回false

验证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"}

我试图验证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"}

我做错了什么?谢谢。

如果有人谈到这一点,我可以先在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>