短信API接口服务

简单接入,稳定可靠,支持多语言SDK

为开发者提供高效便捷的短信API接入方案

短信API接口服务

短信接口API

专业短信API接口服务,满足开发者的各种需求

简单集成

简单集成

提供多种语言的SDK和详细文档,10分钟即可完成接入,开箱即用,专属技术顾问

处理能力

处理能力

验证码2-10秒极速发送,支持3000+条/秒的高并发发送,响应时间≤100ms

高安全性

高安全性

支持IP白名单、频率限制、总量限制、HTTPS加密、号码加密等多重安全和隐秘机制

状态报告

状态报告

实时获取短信发送状态,支持推送和主动查询两种方式,功能全面完善的云控制台

多语言支持

多语言支持

提供Java、PHP、Python、C#、Go等多种语言SDK,开发者友好,定制需求

高可用性

高可用性

99.9%的服务可用性,多机房冗余部署,自动故障切换,自定义余额告警,服务不中断

短信接口API&SDK支持

提供多种语言的SDK,简化开发流程

Java

Java SDK

下载 文档
PHP

PHP SDK

下载 文档
Python

Python SDK

下载 文档
C#

C# SDK

下载 文档
Go

Go SDK

下载 文档
Node.js

Node.js SDK

下载 文档

API演示

体验简单易用的短信API接口

HTTP请求
Java
PHP
Python
C#
Go
Node.js
POST /sms.aspx HTTP/1.1
Host: cloud.thinksms.cn
Content-Type: application/x-www-form-urlencoded

action=send&userid=企业ID&account=账号&password=密码&mobile=13800138000,15900159000&content=【智想云创】您的注册验证码:8899&extno=&rt=json
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;

public class SmsSender {
    public static void main(String[] args) throws Exception {
        String userid = "企业ID";
        String account = "账号";
        String password = "密码";
        String mobile = "13800138000,15900159000";
        String content = URLEncoder.encode("【智想云创】您的注册验证码:8899", "UTF-8");
        
        String urlStr = "http://cloud.thinksms.cn/sms.aspx?action=send&userid=" + userid + 
                        "&account=" + account + "&password=" + password + 
                        "&mobile=" + mobile + "&content=" + content + "&rt=json";
        
        URL url = new URL(urlStr);
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setRequestMethod("POST");
        
        int responseCode = conn.getResponseCode();
        if (responseCode == 200) {
            // 读取响应
            java.io.BufferedReader in = new java.io.BufferedReader(
                new java.io.InputStreamReader(conn.getInputStream()));
            String inputLine;
            StringBuffer response = new StringBuffer();
            while ((inputLine = in.readLine()) != null) {
                response.append(inputLine);
            }
            in.close();
            System.out.println(response.toString());
        }
    }
}
<?php
$userid = "企业ID";
$account = "账号";
$password = "密码";
$mobile = "13800138000,15900159000";
$content = urlencode("【智想云创】您的注册验证码:8899");

$url = "http://cloud.thinksms.cn/sms.aspx";
$data = array(
    'action' => 'send',
    'userid' => $userid,
    'account' => $account,
    'password' => $password,
    'mobile' => $mobile,
    'content' => $content,
    'rt' => 'json'
);

$options = array(
    'http' => array(
        'header' => "Content-type: application/x-www-form-urlencoded\r\n",
        'method' => 'POST',
        'content' => http_build_query($data)
    )
);

$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
echo $result;
?>
import urllib.parse
import urllib.request

userid = "企业ID"
account = "账号"
password = "密码"
mobile = "13800138000,15900159000"
content = "【智想云创】您的注册验证码:8899"

url = "http://cloud.thinksms.cn/sms.aspx"
data = {
    'action': 'send',
    'userid': userid,
    'account': account,
    'password': password,
    'mobile': mobile,
    'content': content,
    'rt': 'json'
}

encoded_data = urllib.parse.urlencode(data).encode('utf-8')
req = urllib.request.Request(url, data=encoded_data, method='POST')
response = urllib.request.urlopen(req)
result = response.read().decode('utf-8')
print(result)
using System;
using System.Net;
using System.Text;

class SmsSender
{
    static void Main()
    {
        string userid = "企业ID";
        string account = "账号";
        string password = "密码";
        string mobile = "13800138000,15900159000";
        string content = Uri.EscapeDataString("【智想云创】您的注册验证码:8899");
        
        string postData = $"action=send&userid={userid}&account={account}&password={password}" +
                          $"&mobile={mobile}&content={content}&rt=json";
        
        WebClient client = new WebClient();
        client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
        string response = client.UploadString("http://cloud.thinksms.cn/sms.aspx", postData);
        Console.WriteLine(response);
    }
}
package main

import (
    "fmt"
    "net/http"
    "net/url"
    "strings"
    "io/ioutil"
)

func main() {
    userid := "企业ID"
    account := "账号"
    password := "密码"
    mobile := "13800138000,15900159000"
    content := "【智想云创】您的注册验证码:8899"
    
    form := url.Values{}
    form.Add("action", "send")
    form.Add("userid", userid)
    form.Add("account", account)
    form.Add("password", password)
    form.Add("mobile", mobile)
    form.Add("content", content)
    form.Add("rt", "json")
    
    req, _ := http.NewRequest("POST", "http://cloud.thinksms.cn/sms.aspx", strings.NewReader(form.Encode()))
    req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
    
    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()
    
    body, _ := ioutil.ReadAll(resp.Body)
    fmt.Println(string(body))
}
const https = require('https');
const querystring = require('querystring');

const userid = "企业ID";
const account = "账号";
const password = "密码";
const mobile = "13800138000,15900159000";
const content = "【智想云创】您的注册验证码:8899";

const postData = querystring.stringify({
    action: 'send',
    userid: userid,
    account: account,
    password: password,
    mobile: mobile,
    content: content,
    rt: 'json'
});

const options = {
    hostname: 'cloud.thinksms.cn',
    port: 80,
    path: '/sms.aspx',
    method: 'POST',
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Content-Length': Buffer.byteLength(postData)
    }
};

const req = https.request(options, (res) => {
    res.setEncoding('utf8');
    let data = '';
    res.on('data', (chunk) => {
        data += chunk;
    });
    res.on('end', () => {
        console.log(data);
    });
});

req.write(postData);
req.end();

响应示例

{
  "ReturnStatus": "Success",
  "Message": "ok",
  "RemainPoint": 109346,
  "TaskID": 365,
  "SuccessCounts": 2
}

字段说明:

  • ReturnStatus: 返回状态值:成功返回Success 失败返回:Faild
  • Message: 返回信息提示
  • RemainPoint: 返回余额
  • TaskID: 返回本次任务的序列ID
  • SuccessCounts: 成功短信数

核心接口功能

全面覆盖短信业务全场景需求,稳定高效的API服务

发送接口

发送接口

支持单发和群发短信,支持定时发送

  • action: send
  • mobile: 接收号码,多个用逗号分隔
  • content: 发送内容,需包含签名
  • sendTime: 定时发送时间(可选)
余额查询

余额查询接口

查询账户余额和已发送量

  • action: overage
  • 返回字段: Payinfo, Overage, SendTotal
  • 支付方式: 预付费/后付费
状态报告

状态报告接口

获取短信发送状态报告

  • action: query
  • statusNum: 每次取得号码数(默认4000)
  • 状态码: 10(成功),20(失败)
推荐
上行接口

上行接口

获取用户回复的短信内容

  • action: query
  • ownExt: 使用自有扩展号(可选)
  • 返回字段: Mobile, Content, ReceiveTime
关键词查询

非法关键词查询

检测短信内容是否包含非法关键词

  • action: checkkeyword
  • content: 需要检测的发送内容
  • 返回结果: 包含非法字符/没有包含屏蔽词
一对一发送

一对一发送

一对一发送,表格短信、文档短信、工资条短信

  • Host: http://cloud.thinksms.com/p2p.aspx
  • action: send
  • mobileContentList: 号码+tab+内容

常见问题

关于短信API接口的常见问题解答

发送短信前需要注意什么?

发送内容最前面须携带短信签名,如:【智想云创】。正式使用前需要先登陆后台提交短信签名认证和模板报备,认证前可使用调试模板对接。注意短信70字按一条计费,超过70字属于长短信,长短信67字按一条计费。

API调用返回"用户名或密码错误"怎么办?

请检查您的企业ID、短信账号和密码是否正确。如果确认信息正确但仍返回错误,请联系客服确认账户状态是否正常,或使用密码修改接口重置密码。

如何获取短信发送状态报告?

可以通过状态报告接口主动查询发送状态,使用action=query参数。状态报告中Status字段值为10表示发送成功,20表示发送失败。相同的状态报告只能获取一次。

短信内容包含非法字符如何处理?

可以使用非法关键词查询接口(action=checkkeyword)预先检测短信内容是否包含屏蔽词。如果检测到非法字符,需要修改内容后再发送。常见非法字符包括敏感词汇、SQL注入字符等。

支持哪些编码格式?

系统支持UTF-8和GBK两种编码格式,不同编码对接地址不同:UTF-8使用http://cloud.thinksms.cn/sms.aspx,GBK使用http://cloud.thinksms.cn/smsGBK.aspx。请注意内容是否乱码,确保使用正确的编码格式。

在线咨询 在线咨询
微信客服

添加微信客服

微信公众号二维码

扫码添加客服微信

客服热线

客服热线

400-668-7332

服务时间: 8:00-22:00