整合阿里云短信服务

整合阿里云短信服务

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

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)));
    }
}
相关推荐
二进制漫游记3 小时前
FastAPI项目集成 Qdrant向量数据库+阿里云Embedding完整实战(工具封装+业务调用)
数据库·python·阿里云·embedding
2501_928996223 小时前
GPT-4o换DeepSeek迁移成本多少?中科热备解析API聚合平台技术账本
前端·数据库·人工智能
Neighbor_OldY5 小时前
云上安全配置审计与误配置修复实战:从安全组、OSS、RAM到数据库的全栈排查复盘
大数据·运维·安全·云计算
泡干脆面就番茄5 小时前
MySQL_子查询_分页查询与联合查询详解
数据库·mysql
devpotato6 小时前
缓存与数据库更新顺序不一致问题
java·数据库·redis
天若有情6736 小时前
Node+MySQL小型全栈笔记项目实战课程分享
数据库·笔记·mysql
wxwx_bscxy3227 小时前
基于springboot宠物领养系统的设计与实现
数据库·spring boot·后端·spring·宠物
九月要晚安7 小时前
达梦DW与AFC对比
数据库
实战派K8S&DB7 小时前
如何在内网配置 TiDB 数据库 Agent
数据库·人工智能·分布式·tidb
实战派K8S&DB7 小时前
《基于 Dify + FastAPI + PyTiDB 搭建大模型驱动的 TiDB 智能运维 Agent》
运维·数据库·分布式·云原生·tidb·fastapi