接入文档

标准 HMAC 签名 + 完整 OpenAPI 文档,5 分钟完成对接

快速接入代码示例(多语言)

const crypto = require('crypto');

const API_KEY = 'your_api_key';
const API_SECRET = 'your_api_secret';
const BASE_URL = 'https://your-domain.com/api/v1';

// 签名串:timestamp \n nonce \n METHOD \n path \n body
function sign(method, path, body, timestamp, nonce) {
  const message = [timestamp, nonce, method.toUpperCase(), path, body].join('\n');
  return crypto.createHmac('sha256', API_SECRET).update(message).digest('hex');
}

async function sendSms(mobile, templateCode, params) {
  const body = JSON.stringify({ mobile, templateCode, params });
  const timestamp = Math.floor(Date.now() / 1000).toString();
  const nonce = crypto.randomBytes(8).toString('hex');
  const signature = sign('POST', '/api/v1/sms/send', body, timestamp, nonce);

  const resp = await fetch(BASE_URL + '/api/v1/sms/send', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'X-Api-Key': API_KEY,
      'X-Timestamp': timestamp,
      'X-Nonce': nonce,
      'X-Signature': signature,
    },
    body,
  });
  return resp.json(); // 异步受理:{ status: "pending", requestId }
}

sendSms('13800000000', 'TPL_001', { code: '1234' }).then(console.log);