2 Star 1 Fork 1

Super 9du/aliyun-sms-spring-boot-starter

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

aliyun-sms-spring-boot-starter

阿里云短信服务 spring-boot-starter。

        JDK 版本: 11
Spring Boot 版本: 2.7.2

用法

  1. 配置(application.properties

    aliyun.sms.accessKeyId=accessKeyId                  # 访问key(必)
    aliyun.sms.accessKeySecret=accessKeySecret          # 访问密钥(必)
    aliyun.sms.signature=signature                      # 短信签名(必)
    aliyun.sms.templates.templateCode1=templateCode1    # 短信模板编号和对应的短信模板变量(至少要配置一个键值对)
    aliyun.sms.templates.templateCode2=templateCode2
    
  2. 代码使用

    import com.aliyun.dysmsapi20170525.Client;
    import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
    import super9du.sia.aliyun.sms.AliyunSmsTemplate;
    
    class Demo {
        /**
         * 获取阿里云 sms 原生的客户端对象
         */
        @Inject
        Client client;
    
        @Inject
        AliyunSmsTemplate template;
    
        void test() throws Exception {
            // 如果只配置了一个「短信模板编号」,那么可以直接使用 sendAuthCode 发送验证码
            SendSmsResponse resp1 = template.sendAuthCode("13245678901");
    
            // 使用阿里云原生的客户端能力
            client.sendSms(template.createSendSmsRequest("短信模板编号", "13245678901", "{\"code\":\"1234\"}"));
            // client.xxx()
        }
    }
    
MIT License Copyright (c) [2022] [super9du] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

阿里云短信服务 spring-boot-starter 展开 收起
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/super9du/aliyun-sms-spring-boot-starter.git
git@gitee.com:super9du/aliyun-sms-spring-boot-starter.git
super9du
aliyun-sms-spring-boot-starter
aliyun-sms-spring-boot-starter
main

搜索帮助