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/109/index.php

返回数据 { "code": 200, "status": "success", "message": "查询成功", "data": { "phone": "18888888888", // 查询手机号 "amount": "100.00" // 话费余额 } }

Example

调用效果 API 调用示例

API 调用示例









						<!DOCTYPE html>
<html>
<head>
  <title>API 调用示例</title>
</head>
<body>
  <h1>API 调用示例</h1>
  <form id="myForm">
    <label for="id">Access ID:</label><br />
    <input type="text" id="id" name="id" /><br />
    <label for="key">Access Key:</label><br />
    <input type="text" id="key" name="key" /><br />
    <label for="channel_id">渠道代码:</label><br />
    <select id="channel_id" name="channel_id">
      <option value="1">联通</option>
      <option value="2">电信</option>
      <option value="3">移动</option>
    </select><br />
    <label for="phone">手机号码:</label><br />
    <input type="text" id="phone" name="phone" /><br />
    <input type="submit" value="提交">
  </form>
  <div id="result"></div>
  <!-- JavaScript to submit form data using XMLHttpRequest -->
  <script>
    document.getElementById("myForm").addEventListener("submit", function(event){
      event.preventDefault()
      var id = document.getElementById("id").value
      var key = document.getElementById("key").value
      var channel_id = document.getElementById("channel_id").value
      var phone = document.getElementById("phone").value
      sendRequest(id, key, channel_id, phone)
    });

    function sendRequest(id, key, channel_id, phone) {
      var xhr = new XMLHttpRequest();
      xhr.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
          var response = JSON.parse(this.responseText);
          document.getElementById("result").innerHTML = "<pre>" + JSON.stringify(response, null, 2) + "</pre>";
          if (response.status == "success") {
            document.getElementById("result").innerHTML += "<p>号码: " + response.data.phone + "</p>";
            document.getElementById("result").innerHTML += "<p>余额: " + response.data.amount + "</p>";
          } else {
            document.getElementById("result").innerHTML += "<p>" + response.message + "</p>";
          }
        }
      };
      xhr.open("POST", "https://api.2su.cc/api/109/index.php", true);
      xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      xhr.send(`id=${encodeURIComponent(id)}&key=${encodeURIComponent(key)}&channel_id=${encodeURIComponent(channel_id)}&phone=${encodeURIComponent(phone)}`);
    }
  </script>
</body>
</html>

					

请求参数

提交方式:POST

参数名称类型是否必须描述
id string Access ID
key string Secret Key
channel_id string 渠道代码:1联通 2电信 3移动
phone string 手机号码