这突然来了,一切都工作正常,直到今天早上,最初我使用的是file_get_contents,它开始抛出SSL错误而无法连接然后我切换到CURL而没有运气。
我使用以下脚本验证表单clientide
<script type="text/javascript">
var renderGoogleInvisibleRecaptcha = function() {
for (var i = 0; i < document.forms.length; ++i) {
var form = document.forms[i];
var holder = form.querySelector('.recaptcha-holder');
if (null === holder){
continue;
}
(function(frm){
var holderId = grecaptcha.render(holder,{
'sitekey': 'my_sitekey',
'size': 'invisible',
'badge' : 'bottomleft', // possible values: bottomright, bottomleft, inline
'callback' : function (recaptchaToken) {
HTMLFormElement.prototype.submit.call(frm);
}
});
frm.onsubmit = function (evt){
evt.preventDefault();
grecaptcha.execute(holderId);
};
})(form);
}
};
和服务器端我使用以下功能
$data = array(
'secret' => "my_secret_key",
'response' => $token // captcha response
);
$verify = curl_init();
curl_setopt($verify, CURLOPT_URL, "http://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);
$response = curl_exec($verify);
然而
var_dump($response); //Always returning false
var_dump(curl_error($verify)); //keep returning "Failed to connect to www.google.com port 80: Connection timed out"
一切都设置正确,它工作了几天但突然停止工作。代码或google recaptcha网站上没有任何变化。