我的recaptcha 有问题。问题是它总是返回错误,这意味着它说验证码失败。即使输入了正确的单词。
一切都是最新的,使用最新的库并三次检查代码和公钥/私钥。
我相信问题就在这里....
require_once('recaptchalib.php');
$privatekey = "************************************";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
$error_string .= '<center>The reCAPTCHA wasnt entered correctly. Go back and try it again.</center><br />';
}
我遵循了这个例子,所以我看不出出了什么问题。坚持了好几天!
https://developers.google.com/recaptcha/docs/php
客户代码:
require_once('recaptchalib.php');
$publickey = "**********************"; // you got this from the signup page
echo recaptcha_get_html($publickey);
对 $resp 变量进行了 var 转储并得到了这个
object(ReCaptchaResponse)#2 (2) { ["is_valid"]=> bool(false) ["error"]=> string(21) "incorrect-captcha-sol" }
还做了一个var_dump
recaptcha响应字段并得到:
NULL
var转储帖子...
array(7) { ["user"]=> string(0) "" ["pass1"]=> string(0) "" ["pass2"]=> string(0) "" ["email"]=> string(0) "" ["email2"]=> string(0) "" ["gender"]=> string(4) "Male" ["register"]=> string(8) "register" }
var转储请求...
array(10) { ["user"]=> string(0) "" ["pass1"]=> string(0) "" ["pass2"]=> string(0) "" ["email"]=> string(0) "" ["email2"]=> string(0) "" ["gender"]=> string(4) "Male" ["register"]=> string(8) "register" ["PHPSESSID"]=> string(26) "4e79u2fdgrrufvb79einufcmq6" ["cprelogin"]=> string(2) "no" ["cpsession"]=> string(65) ":fX5Z1aWfbsgjGfgb3b3J7koo3Y58y5ntgM6k8GTdrQ4YAcqaywAKnD7PRiayfXv3" }