整合阿里云短信服务

整合阿里云短信服务

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

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)));
    }
}
相关推荐
Oueii27 分钟前
Django全栈开发入门:构建一个博客系统
jvm·数据库·python
未来龙皇小蓝1 小时前
【MySQL-索引调优】11:Group by相关概念
数据库·mysql·性能优化
2401_831824961 小时前
使用Fabric自动化你的部署流程
jvm·数据库·python
njidf1 小时前
Python日志记录(Logging)最佳实践
jvm·数据库·python
twc8291 小时前
大模型生成 QA Pairs 提升 RAG 应用测试效率的实践
服务器·数据库·人工智能·windows·rag·大模型测试
@我漫长的孤独流浪1 小时前
Python编程核心知识点速览
开发语言·数据库·python
2401_851272991 小时前
实战:用Python分析某电商销售数据
jvm·数据库·python
枕布响丸辣2 小时前
MySQL 从入门到精通:完整操作手册与实战指南
数据库·mysql
电商API&Tina2 小时前
【电商API接口】开发者一站式电商API接入说明
大数据·数据库·人工智能·云计算·json
2401_857918292 小时前
用Python和Twilio构建短信通知系统
jvm·数据库·python