整合阿里云短信服务

整合阿里云短信服务

一、开通阿里云短信服务步骤

1.1登录阿里云找到短信服务

1.2申请模板管理

1.3申请签名管理

1.4(看是否需要)创建阿里云OSS许可证

阿里云颁发ID与秘钥,如果要使用OSS对象存储,要使用OSS许可证,首先需要创建Bucket


1.5创建Access Key


二、代码实现


2.1依赖

xml 复制代码
<dependency>
  <groupId>com.aliyun</groupId>
  <artifactId>tea-openapi</artifactId>
  <version>0.0.19</version>
</dependency>
<dependency>
  <groupId>com.aliyun</groupId>
  <artifactId>dysmsapi20170525</artifactId>
  <version>2.0.6</version>
</dependency>

编写test

还会在学习的,到时候完善

https://blog.csdn.net/Serendipity_o/article/details/124369637

java 复制代码
package com.gxa.test;// This file is auto-generated, don't edit it. Thanks.


import com.aliyun.tea.*;
import com.aliyun.dysmsapi20170525.*;
import com.aliyun.dysmsapi20170525.models.*;
import com.aliyun.teaopenapi.*;
import com.aliyun.teaopenapi.models.*;
import com.aliyun.teaconsole.*;
import com.aliyun.teautil.*;
import com.aliyun.teautil.models.*;

public class Sample {

    /**
     * 使用AK&SK初始化账号Client
     * @param accessKeyId
     * @param accessKeySecret
     * @return Client
     * @throws Exception
     */
    public static com.aliyun.dysmsapi20170525.Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
        Config config = new Config()
                // 您的 AccessKey ID
                .setAccessKeyId(accessKeyId)
                // 您的 AccessKey Secret
                .setAccessKeySecret(accessKeySecret);
        // 访问的域名
        config.endpoint = "dysmsapi.aliyuncs.com";
        return new com.aliyun.dysmsapi20170525.Client(config);
    }

    public static void main(String[] args_) throws Exception {
        java.util.List<String> args = java.util.Arrays.asList(args_);
        com.aliyun.dysmsapi20170525.Client client = Sample.createClient("ACCESS_KEY_ID", "ACCESS_KEY_SECRET");
        SendSmsRequest sendSmsRequest = new SendSmsRequest()
                .setPhoneNumbers("15884226919")
                .setSignName("刀锋之影")
                .setTemplateCode("SMS_199796966")
                .setTemplateParam("{\"code\":\"1234\"}");
        RuntimeOptions runtime = new RuntimeOptions();
        SendSmsResponse resp = client.sendSmsWithOptions(sendSmsRequest, runtime);
        com.aliyun.teaconsole.Client.log(com.aliyun.teautil.Common.toJSONString(TeaModel.buildMap(resp)));
    }
}
相关推荐
香蕉鼠片2 分钟前
Mysql进阶篇
数据库·mysql·oracle
数厘3 分钟前
2.12 sql 数据插入(INSERT INTO)
数据库·sql·oracle
薛定e的猫咪4 分钟前
2026 年 4 月实测:OpenAI Codex 保姆级教程,从安装到 MCP、Skills 与多智能体协作
前端·数据库·人工智能
wgzrmlrm745 分钟前
Django怎么优雅发送邮件_Python配置SMTP后端实现异步通知
jvm·数据库·python
014-code7 分钟前
Redis 删除缓存失败怎么办?重试、死信、补偿的工程化方案
数据库·redis·缓存
I love studying!!!8 分钟前
Web应用程序:用户账户
前端·数据库·sqlite
窝子面12 分钟前
NestJs+MongoDB+Deepseek+Langchain实现ai聊天助手
javascript·数据库·人工智能·mongodb
zjshuster13 分钟前
流程引擎(Process Engine)简介
java·数据库·servlet
主机哥哥17 分钟前
2026年腾讯云优惠券领取攻略:新购/续费/升级可用
云计算·腾讯云
leonkay27 分钟前
关于.NET中的队列理解
数据库·性能优化·.net·个人开发·设计规范·队列