menu So ' Api 文章列表
dvr
小米
keyboard_arrow_down
dvr
微短信
keyboard_arrow_down
dvr
云码
keyboard_arrow_down
dvr
腾讯
keyboard_arrow_down
dvr
宝塔面板
keyboard_arrow_down
last_page
last_page
last_page
last_page

短信验证码派发

使用教程


请求地址 https://api.2su.cc/api/114/

返回数据 { "code": 200, "msg": "验证码发送成功!" }

Example

调用效果 验证码验证示例

验证码验证示例







						<!DOCTYPE html>
<html>
<head>
  <title>验证码验证示例</title>
</head>
<body>
  <h1>验证码验证示例</h1>
  <form id="myForm">
    <label for="phone">手机号:</label><br>
    <input type="text" id="phone" name="phone"><br><br>
    <label for="code">验证码:</label><br>
    <input type="text" id="code" name="code"><br><br>
    <input type="button" id="getCode" value="获取验证码">
    <input type="submit" value="验证验证码">
  </form>
  <div id="result"></div>
  <script>
    document.getElementById("getCode").addEventListener("click", function(){
      var phone = document.getElementById("phone").value
      var xhr = new XMLHttpRequest();
      xhr.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
          var response = JSON.parse(this.responseText);
          document.getElementById("result").innerHTML = "<p>" + response.msg + "</p>";
        }
      };
      xhr.open("GET", "https://api.2su.cc/api/114/?act=getCode&phone="+phone, true);
      xhr.send();
    });

    document.getElementById("myForm").addEventListener("submit", function(event){
      event.preventDefault()
      var phone = document.getElementById("phone").value
      var code = document.getElementById("code").value
      var xhr = new XMLHttpRequest();
      xhr.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
          var response = JSON.parse(this.responseText);
          document.getElementById("result").innerHTML = "<p>" + response.msg + "</p>";
        }
      };
      xhr.open("GET", "https://api.2su.cc/api/114/?act=isCode&phone="+phone+"&code="+code, true);
      xhr.send();
    });
  </script>
</body>
</html>

					

请求参数

提交方式:GET

参数名称类型是否必填描述
act string 行为:getCode(发送验证码)|isCode(校验验证码)
phone string 手机号
code string 验证码