[PHP] 接口增加recaptcha行为验证
发布时间:2021-05-21 06:53:31 所属栏目:大数据 来源: https://www.jb51.cc
导读:需要先翻墙创建一个谷歌账户和创建recaptcha验证的网站域名,获取到两个secrect https://www.google.com/recaptcha/admin ? 前端增加html和js代码,例如 input type ="hidden" name ="token" id ="token" / script src ="https://www.recaptcha.net/recaptcha/
需要先翻墙创建一个谷歌账户和创建recaptcha验证的网站域名,获取到两个secrect ? 前端增加html和js代码,例如 <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']){ ... } ? (编辑:北几岛) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |