gpt4 book ai didi

php - 由于 "invalid-input-secret",google recaptcha 返回 false

转载 作者:行者123 更新时间:2023-12-02 06:15:11 24 4
gpt4 key购买 nike

我已经从 google 安装了最新的 recaptcha,但它总是在提交后返回 false 并且总是返回“invalid-input-secret”错误,即使从前端 View 验证总是正确的。这可能是什么原因。顺便说一句,我正在使用 phalcon 框架测试 localhost xampp 中的所有内容。这是我检查验证码的部分:

protected function validate_data($post, $ip){

$validation = new Validation();
$validation->add(
'user_name',
new PresenceOf(
array(
'message' => 'The Username is required'
)
)
);
$validation->add(
'email',
new PresenceOf(
array(
'message' => 'The e-mail is required'
)
)
);
$validation->add(
'password',
new PresenceOf(
array(
'message' => 'The Password is required'
)
)
);
$validation->add(
'cpassword',
new PresenceOf(
array(
'message' => 'The Confirmation Password is required'
)
)
);
$validation->add(
'email',
new Email(
array(
'message' => 'The e-mail is not valid'
)
)
);

$validation->add('password',
new Confirmation(array(
'message' => 'Password doesn\'t match confirmation',
'with' => 'cpassword'
)
)
);

$error = $validation->validate($post);
$errors = array();
if(count($error)){
foreach($error as $e){
$errors[] = $e;
}
}

$data = array(
'secret' => "my secret key",
'response' => $post['g-recaptcha-response'],
'remoteip' => $ip
);

$verify = curl_init();
curl_setopt($verify, CURLOPT_URL, "https://www.google.com/recaptcha/api/siteverify");
curl_setopt($verify, CURLOPT_POST, true);
curl_setopt($verify, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($verify, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($verify, CURLOPT_RETURNTRANSFER, true);
$res = curl_exec($verify);

$captcha = json_decode($res);

if($captcha->success == false){
$errors[] = "Invalid Captcha, You are a freakin robot!";
}

return $errors;

}

这可能是什么原因?这是转储响应时的输出:
object(stdClass)#70 (2) { ["success"]=> bool(false) ["error-codes"]=> array(1) { [0]=> string(20) "invalid-input-secret" } } 

最佳答案

愚蠢的我,我仔细检查了 key ,一开始只缺少一个字符。那解决了它。

关于php - 由于 "invalid-input-secret",google recaptcha 返回 false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36939870/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com