HM-Captcha 演示

一个验证服务平台,为其他应用提供防止机器人自动化访问的验证能力

应用配置

此处填入在平台申请的应用ID和应用密钥;初始化验证码时所需要的签名应在后台服务器中实现,此处仅为测试

文字验证码

点击按钮加载验证码
验证结果将显示在这里

滑块验证码

点击按钮加载验证码
验证结果将显示在这里

点选验证码

点击按钮加载验证码
验证结果将显示在这里

集成代码示例

        
          // 引入SDK /js/hm-captcha.js
          <script src="/js/hm-captcha.js"></script>
          // 初始化验证码
          const captcha = new HMCaptcha({
            appId: 'your-app-id',
            type: 'text', // 'text', 'slide', 'click'
            container: '#captcha-container',
            timestamp: timestamp,
            signature: signature,
            useCustomUI: false, // 是否使用自定义UI,开启是可通过onLoad方法中返回的captcha对象调用自定义UI方法
            captchaConfig: {
              // 文字验证码的配置,可选,若未提供则会根据创建应用时填写的默认配置
              textSize: 4,
              textWidth: 150,
              textHeight: 75,
              // 滑块验证码的配置,可选,若未提供则会根据创建应用时填写的默认配置
              sliderViewWidth: 300,
              sliderViewHeight: 200,
              slideWidth: 60,
              slideHeight: 40,
              sliderRadius: 8,
            },
            onLoad: function(captcha) {
              console.log('验证码加载完成:', captcha);
            },
            onSuccess: function(token) {
              console.log('验证成功,令牌:', token);
            },
            onError: function(error) {
              console.error('验证失败:', error);
            }
          });