谷歌验证码内部错误

Google Recaptcha Internal Error

本文关键字:错误 内部 验证 谷歌      更新时间:2023-09-26

我正在使用新的Google reCaptcha API作为WordPress实例页面内的联系表单,但是使用Google给出的脚本时API returns a 500 Internal Server Error message
所以,我正在使用这段代码来使其工作

$siteKey = "sitekey";
$secret = "secretkey";
$lang = "it";
$resp = null;
$error = null;
$reCaptcha = new ReCaptcha($secret);
if ($_POST["g-recaptcha-response"]) {
    $resp = $reCaptcha->verifyResponse(
        $_SERVER["REMOTE_ADDR"],
        $_POST["g-recaptcha-response"]
    );
}

并且,在 HTML 上:

<script src='https://www.google.com/recaptcha/api.js'></script>
<div class="g-recaptcha" data-sitekey="<?php echo siteKey; ?>"></div>

但是,当我打开该页面时,我唯一看到的是:

An error occurred:  
An internal error occurred: 50C0C9A3E5F28.AB460A3.4C003672

顺便说一下,在谷歌浏览器控制台上,我可以点击API脚本生成的URL,当我打开它时,我看到一个空白页面,其中包含我需要的reCaptcha。

可能是Google reCaptcha API和Wordpress之间的冲突,还是只是API的错误?

您收到此错误是因为您没有将域放入recaptcha管理站点的密钥设置或基本上错误的域。

我已经

解决了这个问题,但有趣的是我不知道怎么做,我只是从 Google 文档中重新复制了代码,也许打错了。
无论如何,问题解决了。