整合阿里云短信服务

整合阿里云短信服务

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

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)));
    }
}
相关推荐
DBA_G7 小时前
GBase 8a数据库集群多维度资源管控策略矩阵解析
数据库·oracle
怪奇云呼军7 小时前
G.711、Opus 和重采样会拖慢识别吗?闪电智能VoiceAgent 的音频入口怎么选
java·人工智能·python·算法·云计算·音视频
workflower7 小时前
例二:某汽车制造企业深度融合AI智能体,构建园区网络的智能运维体系
人工智能·机器学习·设计模式·机器人·云计算·汽车·制造
逐米时代8 小时前
智能招聘与人岗匹配:可解释匹配让录用依据有迹可循
大数据·数据库·人工智能
承渊政道8 小时前
KES专业技能包发布:覆盖数据库开发、迁移与运维全流程
运维·数据库·gitee·数据库开发·金仓数据库
IvorySQL8 小时前
PostgreSQL 日报| RI 快速路径并发读取缺陷(8 月 13 日)
数据库·postgresql
highreport9 小时前
HighReport报表工具定时调度和邮件定时发送
运维·服务器·数据库
01_ice9 小时前
数据库基础
数据库
deepdata_cn9 小时前
向量数据库是非结构化数据的AI检索底座
数据库·人工智能
梁辰兴9 小时前
软件工程:数据库设计
数据库·软件工程·数据库设计·逻辑设计·概念设计·梁辰兴·物理设计