Class HuaweiSmsSender

java.lang.Object
cloud.opencode.base.sms.provider.HuaweiSmsSender
All Implemented Interfaces:
SmsProvider

public class HuaweiSmsSender extends Object implements SmsProvider
Huawei Cloud SMS Sender 华为云短信发送器

SMS sender implementation for Huawei Cloud using WSSE authentication. Supports batch SMS sending via Huawei Cloud SMS API.

使用WSSE认证的华为云短信发送器实现。 支持通过华为云短信API批量发送短信。

Features | 主要功能:

  • WSSE authentication - WSSE认证
  • Single and batch SMS sending - 单条和批量短信发送
  • Template-based messaging - 基于模板的消息
  • Virtual thread HTTP client - 虚拟线程HTTP客户端

Usage Example | 使用示例

var config = new HuaweiSmsConfig(
    "your-app-key",
    "your-app-secret",
    "sender-channel",
    "channel-id",
    "cn-north-4"
);
var sender = HuaweiSmsSender.create(config);
var result = sender.send(SmsMessage.of("+8613800138000", "Your code is 123456"));

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:
  • Method Details

    • create

      public static HuaweiSmsSender create(HuaweiSmsSender.HuaweiSmsConfig config)
      Create Huawei SMS sender with config 使用配置创建华为短信发送器
      Parameters:
      config - the configuration | 配置
      Returns:
      the sender instance | 发送器实例
    • send

      public SmsResult send(SmsMessage message)
      Description copied from interface: SmsProvider
      Send single SMS 发送单条短信
      Specified by:
      send in interface SmsProvider
      Parameters:
      message - the message | 消息
      Returns:
      the result | 结果
    • sendBatch

      public List<SmsResult> sendBatch(List<SmsMessage> messages)
      Description copied from interface: SmsProvider
      Send batch SMS 批量发送短信
      Specified by:
      sendBatch in interface SmsProvider
      Parameters:
      messages - the messages | 消息列表
      Returns:
      the results | 结果列表
    • getName

      public String getName()
      Description copied from interface: SmsProvider
      Get provider name 获取提供商名称
      Specified by:
      getName in interface SmsProvider
      Returns:
      the name | 名称
    • isAvailable

      public boolean isAvailable()
      Description copied from interface: SmsProvider
      Check if provider is available 检查提供商是否可用
      Specified by:
      isAvailable in interface SmsProvider
      Returns:
      true if available | 如果可用返回true
    • getConfig

      public HuaweiSmsSender.HuaweiSmsConfig getConfig()
      Get the configuration 获取配置
      Returns:
      the config | 配置
    • getEndpoint

      public String getEndpoint()
      Get the endpoint URL 获取端点URL
      Returns:
      the endpoint | 端点