Php GoogleRecapTChav2。多森´;我不能以我的方式工作

Php GoogleRecapTChav2。多森´;我不能以我的方式工作,php,forms,recaptcha,captcha,Php,Forms,Recaptcha,Captcha,我正在使用googleReCaptcha v2。在我的网站上,针对两种形式(和) 如果我填写所有输入字段并希望接受Capchta,那么它将显示我的错误消息。我检查了钥匙,钥匙没问题。有人知道出了什么问题吗 我们的验证码类: class Captcha { function check($response) { $url = 'https://www.google.com/recaptcha/api/siteverify'; $data = ar

我正在使用google
ReCaptcha v2
。在我的网站上,针对两种形式(和)

如果我填写所有输入字段并希望接受Capchta,那么它将显示我的错误消息。我检查了钥匙,钥匙没问题。有人知道出了什么问题吗

我们的验证码类:

    class Captcha {

    function check($response) {

        $url = 'https://www.google.com/recaptcha/api/siteverify';
        $data = array(
            'secret' => 'KEY',
            'response' => $response
        );

        $options = array(
            'http' => array(
                'method' => 'POST',
                'content' => http_build_query($data)
            )
        );
        $context = stream_context_create($options);

        $verify = file_get_contents($url, false, $context);
        $captcha_success = json_decode($verify);



        return ($captcha_success -> success == true);
    }
}
我们的表格:

<div id="content">

            <?php
                include_once "../../../hidden/php/Newsletter.php";
            ?>

            <form method="post">

                <div id="field">
                    <input class="input-style large-input" type="email" name="e-mail" placeholder="E-Mail" required>
                </div>

                <div class="center">
                    <div class="g-recaptcha" data-sitekey="KEY"></div>
                </div>
                <br>

                <div id="subscribe">
                    <input class="primary-button" type="submit" name="subscribe" data-custom_value="submit">
                </div>

            </form>

        </div>



Do
var\u dump($verify)
在定义$verify之后。您将看到recaptcha服务器实际响应的是什么。bool=false,但原因是什么。所有键都已更正添加
'ignore\u errors'=>true
'content'=>http\u build\u query($data)
之后,您得到的“false”将替换为http响应。这将帮助你找到为什么你只会得到“假”的原因。