Class TencentSmsSender
java.lang.Object
cloud.opencode.base.sms.provider.TencentSmsSender
- All Implemented Interfaces:
SmsProvider
Tencent Cloud SMS Sender
腾讯云短信发送器
SMS sender implementation for Tencent Cloud using TC3-HMAC-SHA256 signature.
使用TC3-HMAC-SHA256签名的腾讯云短信发送器实现。
Features | 主要功能:
- Single SMS sending - 单条短信发送
- Batch SMS sending - 批量短信发送
- Template-based messaging - 基于模板的消息
- TC3-HMAC-SHA256 authentication - TC3-HMAC-SHA256认证
Example usage | 使用示例:
var config = new TencentSmsConfig(
"your-secret-id",
"your-secret-key",
"1400000000",
"YourSign",
"ap-guangzhou"
);
var sender = TencentSmsSender.create(config);
var message = SmsMessage.ofTemplate("+8613800138000", "123456", Map.of("code", "1234"));
var result = sender.send(message);
Security | 安全性:
- Thread-safe: Yes (immutable config, shared HttpClient) - 线程安全: 是(不可变配置,共享HttpClient)
- Since:
- JDK 25, opencode-base-sms V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordTencent SMS Configuration 腾讯云短信配置 -
Method Summary
Modifier and TypeMethodDescriptionstatic TencentSmsSenderCreate Tencent SMS sender 创建腾讯云短信发送器Get the configuration 获取配置getName()Get provider name 获取提供商名称booleanCheck if provider is available 检查提供商是否可用send(SmsMessage message) Send SMS message 发送短信消息sendBatch(List<SmsMessage> messages) Send batch SMS messages 批量发送短信消息Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface SmsProvider
close
-
Method Details
-
create
Create Tencent SMS sender 创建腾讯云短信发送器Factory method to create a new sender instance.
用于创建新发送器实例的工厂方法。
- Parameters:
config- the configuration | 配置- Returns:
- new sender instance | 新的发送器实例
- Throws:
IllegalArgumentException- if config is null or invalid | 如果配置为空或无效
-
send
Send SMS message 发送短信消息Sends a single SMS message using Tencent Cloud SMS API.
使用腾讯云短信API发送单条短信消息。
- Specified by:
sendin interfaceSmsProvider- Parameters:
message- the message to send | 要发送的消息- Returns:
- the send result | 发送结果
-
sendBatch
Send batch SMS messages 批量发送短信消息Sends multiple SMS messages in parallel using virtual threads.
使用虚拟线程并行发送多条短信消息。
- Specified by:
sendBatchin interfaceSmsProvider- Parameters:
messages- the messages to send | 要发送的消息列表- Returns:
- list of send results | 发送结果列表
-
getName
Get provider name 获取提供商名称- Specified by:
getNamein interfaceSmsProvider- Returns:
- the provider name | 提供商名称
-
isAvailable
public boolean isAvailable()Check if provider is available 检查提供商是否可用- Specified by:
isAvailablein interfaceSmsProvider- Returns:
- true if available | 如果可用返回true
-
getConfig
Get the configuration 获取配置- Returns:
- the configuration | 配置
-