腾讯云短信

130 阅读1分钟

腾讯云短信

短信 Java SDK-SDK 文档-文档中心-腾讯云 (tencent.com)

错误码-短信-文档中心-腾讯云 (tencent.com)

依赖的引入

<dependency>
    <groupId>com.tencentcloudapi</groupId>
    <artifactId>tencentcloud-sdk-java</artifactId>
    <!-- go to https://search.maven.org/search?q=tencentcloud-sdk-java and get the latest version. -->
    <!-- 请到https://search.maven.org/search?q=tencentcloud-sdk-java查询所有版本,最新版本如下 -->
    <version>3.1.791</version>
</dependency>
package com.example.portablefortheelderlybackground.config.Tencent.SMS;

import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

/**
 * @author tzf
 * @description: 腾讯云的ApiId
 * @date: 2023/7/4 11:01
 */
@Component
public class ApiId {
    //    @Value("${sms.module.minute}")
//    public  String minute;
    // 密钥id
    public static final String secretId = "AKIDDJC2f4GF1aHl9KI2Zu65rTwCG8oNlwsE";
    // 密钥值
    public static final String secretKey = "CBwV2PahcJqBKGzTWP6ZptlV4Ys1xjKi";
    // 短信应用id
    public static final String sdkAppId = "1400835995";
    // 短信模板签证名
    public static final String signName = "西红柿要用热水烫个人网";
    // 模板id
    public static final String templateId = "1853165";

    // 模板参数
    public static String[] generateTemplateParamSet(String code) {
        return new String[]{code, "5"};
    }

    // 构建phoneNumSet
    public static String[] generatePhoneNumSet(String... phone) {
        String[] res = new String[phone.length];
        int index = 0;
        for (String s : phone) {
            if (StringUtils.hasLength(s)) {
                res[index++] = s;
            }
        }
        return res;
    }
}