ReCAPTCHA总是不正确

阿基尔·古普塔(Akhil Gupta)

我的页面上有一个Recaptcha,它已经运行了两个月,没有任何问题。但是现在,几天以来,它一直表现得很奇怪。我已经尝试了很多次,但验证码根本无法正常工作。

这是代码

$captcharesponse = test_input($_POST["g-recaptcha-response"]);
$status = captcha($captcharesponse);
...
function captcha($t){
    $captcharesponse = $t;
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_URL, 'https://www.google.com/recaptcha/api/siteverify');
    curl_setopt($curl, CURLOPT_POSTFIELDS, 'secret=7...PRIVATE_KEY...S&response=' . $captcharesponse);

    $result = json_decode(curl_exec($curl), true);
    curl_close($curl);

    if($result['success'] == false){
        error_log(date("Y-M-d, D h:i:s A") . " : Result = " . $result['success'] . ", and error = " . $result['error-codes']);
    }
    return $result['success'];      
}

而且无论如何,即使我什至没有输入验证码,页面仍然花费了很长时间,因此没有任何作用。请注意,如果验证码错误,其他内容将被简单地跳过,因此,其他任何方式都不会导致延迟。

提前致谢

PS。我没有使用任何种类或库,也没有使用任何东西,并且确实可以工作一段时间,而且没有任何问题。

'test_input()'代码:

function test_input($data){
       $data = trim($data);
       $data = stripslashes($data);
       $data = htmlspecialchars($data);
       return $data;
}
阿基尔·古普塔(Akhil Gupta)

该问题已解决,显然这是reCAPTCHA的问题。上面提供的代码现在可以正常工作,并且所有慢速性能问题也已解决。

谢谢你们。

PS。其他人可以根据需要使用此代码。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章