1、官方下载文档
https://github.com/GeeTeam/gt3-dotnet-sdk
2、下载极验官方geetest包
pip install geetest
3、根据不同开发环境选择对应文档包,以Django为例:
Ajax方式验证:
<script> var handlerPopup = function (captchaObj) { captchaObj.onSuccess(function () { var validate = captchaObj.getValidate(); var $spanEle = $('.error') $.ajax({ url: "/login_geetest/", //第二次校验,验证用户名密码 type: "post", dataType: "json", data: { username: $('#inputUser').val(), password: $('#inputPassword').val(), geetest_challenge: validate.geetest_challenge, geetest_validate: validate.geetest_validate, geetest_seccode: validate.geetest_seccode }, success: function (msg) { if (msg.state == 1) { $spanEle.text(msg.error) $spanEle.parent().parent().addClass(msg.class) } else { {##结合auth模块的登录校验装饰器,获取需要访问url路由地址,实现登陆成功后,重定向到该地址#} var url = location.search if (url.indexOf("?") != -1) { var str = url.substr(1); strs = str.split("="); location.href = strs[1]; } else { location.href = '/index/'; } } } }); }); $("#login").click(function () { captchaObj.show(); }); // 将验证码加到id为captcha的元素里 captchaObj.appendTo("#popup-captcha"); }; // 验证开始需要向网站主后台获取id,challenge,success(是否启用failback) $.ajax({ url: "/geetest/register?t=" + (new Date()).getTime(), // 加随机数防止缓存, 第一次校验,验证极验图片 type: "get", dataType: "json", success: function (data) { // 使用initGeetest接口 // 参数1:配置参数 // 参数2:回调,回调的第一个参数验证码对象,之后可以使用它做appendTo之类的事件 initGeetest({ gt: data.gt, challenge: data.challenge, product: "popup", // 产品形式,包括:float,embed,popup。注意只对PC版验证码有效 offline: !data.success, // 表示用户后台检测极验服务器是否宕机,一般不需要关注 new_captcha: data.new_captcha }, handlerPopup); } }); </script>