JAVA 短信API接口调用 附 文档 Demo

1.请求地址

http://host:port/sms请求方式可以 POST 和 GET方式,建议采用POST方式

2.参数说明

参数需要 URLENCODE,编码方式采用UTF-8

参数名称

含义

说明

action

请求动作

设置为固定的:send

account

发送用户帐号

用户帐号,由系统管理员

password

请求密码

加密:MD5(UTF-8(password+extno+content+mobile)) ,参数加密的password是明文,请求的时候用加密的密文请求

mobile

全部被叫号码

发信发送的目的号码.多个号码之间用半角逗号隔开,最多500个号码

content

发送内容

短信的内容,内容需要UTF-8 URLEncode编码

extno

接入号

接入号,即SP服务号

rt

响应数据类型

json

例如:

http://host:port/sms?action=send&account=账号&password=密码&mobile=15023239810,13527576163&content=内容&extno=1069012345&rt=json

3.响应数据

{
    "status": "0",
    "balance": -153278040,
    "list": [
        {
            "mid": "4C2CA88382720003",
            "mobile": "18983437010",
            "result": 0
        },
        {
            "mid": "4C2CA88382720004",
            "mobile": "18983437011",
            "result": 0
        }
    ]
}

字段

说明

status

请求结果,具体参见STATUS错误代码表

balance

当前账户余额,单位厘

list

短信提交响应列表

mid

消息ID(用于状态报告匹配)

mobile

手机号码

result

短信提交错误代码,参见RESULT错误代码表

4.STATUS错误代码表

java短信调接口开发 java调用短信接口_demo

5.RESULT错误代码表

java短信调接口开发 java调用短信接口_短信_02

6 .JAVA Demo

public class SMS {

    private static final String Url = "";

    public void smssend(String account
            ,String password
            ,String mobile
            ,String content
            ,String extno) throws UnsupportedEncodingException {
        String beforemdStr =password+extno+content+mobile;
        String mdStr = MD5Utils.getPwd(password+extno+content+mobile);
        System.out.println(beforemdStr);
        System.out.println(mdStr);
        StringBuffer sb = new StringBuffer("action=send&");
        sb.append("account=").append(account);
        sb.append("&password=").append(mdStr);
        sb.append("&mobile=").append(mobile);
        sb.append("&content=").append(URLEncoder.encode(content,"utf-8"));
        sb.append("&extno=").append(extno);
        sb.append("&rt=json");
        String postdata=sb.toString();
        System.out.println(postdata);
        String result = HttpRequest.sendPost(Url, postdata);
        System.out.println(result);
    }
    public static void main(String[] args) throws UnsupportedEncodingException {
        String account="";
        String password ="";
        String mobile="";
        // 【签名】短信内容
        String content="【小米】登录/注册小米帐号验证码:123456,请勿转发,转发将导致帐号被盗。本验证码5分钟有效。注册后将绑定此安全手机。";
        String extno="";
        SMS sms = new SMS();
        sms.smssend(account,password,mobile,content,extno);
    }
}

效果截图

java短信调接口开发 java调用短信接口_短信_03

7.免费接口参数获取

  1. 加企 鹅944472816 ,备注:短信测试
  2. 一般验证码短信可以直接调用。但是有其他短信内容需要申请一下
  3. 获取账号参数之后,打开后台网址 。充值一块钱 ,就可以直接发送了。单价默认都是3.4分/条。大概可以测试30条。

java短信调接口开发 java调用短信接口_demo_04

这个不是打广告呀,只是朋友是这个的代理,现在阿里云,腾讯云价格都比这个高。
而且最低只需要充值1块钱。是针对学生党白嫖测试的福利。所以才会推荐一下。🙃