需要先翻墙创建一个谷歌账户和创建recaptcha验证的网站域名,获取到两个secrect
https://www.google.com/recaptcha/admin
<input type="hidden" name="token" id="token" /> script src="https://www.recaptcha.net/recaptcha/api.js?render=客户端scerect"></script> > grecaptcha.ready(function() { grecaptcha.execute('客户端scerect,{action: homepage}).then((token) { $(#token).val(token); }); }); </>
post请求https://www.recaptcha.net/recaptcha/api/siteverify, $tokenVerify=array(); $tokenVerify['secret']='服务端secrect'; $tokenVerify['response']=$params['token']; $tokenResponse=post("https://www.recaptcha.net/recaptcha/api/siteverify",$tokenVerify); if(empty($tokenArr)||!$tokenArr['success']){ ... }