我有一个使用新版Google ReCaptcha的网站(我不是机器人版),但我在共享服务器上遇到质询响应时遇到了问题。
由于服务器的限制,我无法使用curl或file_get_contents。有没有其他方法可以得到答复?
我在本地使用的代码在实时网站上不起作用:
CURL
function get_data($url) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$response=$this->get_curl_response("https://www.google.com/recaptcha/api/siteverify?secret=SECRET&response=".$_POST['g-recaptcha-response']."&remoteip=".$_SERVER['REMOTE_ADDR']);
文件获取内容
$response=$this->get_curl_response("https://www.google.com/recaptcha/api/siteverify?secret=SECRET&response=".$_POST['g-recaptcha-response']."&remoteip=".$_SERVER['REMOTE_ADDR']);
答案 0 :(得分:0)
这对主机公司来说是一个无法解决的问题,来自验证码的挑战响应被托管公司的防火墙阻止,因此capthcha总是失败。
因为我在共享服务器上,所以无法启用file_get_contents(),因为这会对该服务器上的所有站点造成安全风险。
我安装了PHP Captcha(https://www.phpcaptcha.org/)作为替代方案,因为所有逻辑都在本地完成,所以它可以正常工作。