ReCaptcha 总是返回 false,没有错误 [英] ReCaptcha always returns false, with no error

查看:42
本文介绍了ReCaptcha 总是返回 false,没有错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了 ReCaptcha,配置了我的公钥和私钥,一切都很好,直到我在上面输入任何答案,无论它是好是错,它甚至没有响应发生的错误.

I've installed the ReCaptcha, configured my public and private key, and everything is fine until I type any answer on it, no matter if it's good or wrong, it doesn't even respond with the error there was occurred.

这是我的代码:

require_once('recaptchalib.php');
$resp = recaptcha_check_answer ($config->privkey,   $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);

if (!$resp->is_valid) {
    echo $resp->error;
}

推荐答案

经过几天的搜索,我找到了答案...

I've found the answer after days of searching...

如果有人遇到类似问题,这里是解决方案:

Here is the solution if someone is having a similar problem:

在您的 rechatchalib.php 中更改:

define("RECAPTCHA_API_SERVER", "http://api.recaptcha.net");
define("RECAPTCHA_API_SECURE_SERVER", "https://api-secure.recaptcha.net");
define("RECAPTCHA_VERIFY_SERVER", gethostbyname('api-verify.recaptcha.net'));

致:

define("RECAPTCHA_API_SERVER", "http://www.google.com/recaptcha/api");
define("RECAPTCHA_API_SECURE_SERVER", "https://www.google.com/recaptcha/api");
define("RECAPTCHA_VERIFY_SERVER", "www.google.com");

可能是PHP库过时造成的,最好也下载最新的库:

It was probably caused by the outdated PHP library, so it'll be better for you to download the latest library also:

http://code.google.com/p/recaptcha/downloads/list?q=label:phplib-最新

谢谢大家.

这篇关于ReCaptcha 总是返回 false,没有错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆