Class HttpSmsProvider
java.lang.Object
cloud.opencode.base.sms.provider.HttpSmsProvider
- All Implemented Interfaces:
SmsProvider
HTTP SMS Provider
HTTP短信提供商
Generic HTTP-based SMS provider.
通用的基于HTTP的短信提供商。
Features | 主要功能:
- Generic HTTP API integration - 通用HTTP API集成
- Configurable authentication headers - 可配置认证头
- Parallel batch sending - 并行批量发送
Usage Examples | 使用示例:
HttpSmsConfig config = HttpSmsConfig.builder()
.apiUrl("https://sms-api.example.com/send")
.appId("id").appKey("key").build();
HttpSmsProvider provider = new HttpSmsProvider(config);
SmsResult result = provider.send(SmsMessage.of("13800138000", "Hello"));
Security | 安全性:
- Thread-safe: Yes (shared HttpClient, immutable config) - 线程安全: 是(共享HttpClient,不可变配置)
- Since:
- JDK 25, opencode-base-sms V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected String[]Build auth headers 构建认证头protected StringbuildRequestBody(SmsMessage message) Build request body 构建请求体protected HttpSmsConfigGet config 获取配置protected HttpClientGet shared HTTP client 获取共享HTTP客户端getName()Get provider name 获取提供商名称booleanCheck if provider is available 检查提供商是否可用protected SmsResultparseResponse(String body, int statusCode) Parse response 解析响应send(SmsMessage message) Send single SMS 发送单条短信sendBatch(List<SmsMessage> messages) Send batch SMS 批量发送短信Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface SmsProvider
close
-
Constructor Details
-
HttpSmsProvider
Create HTTP SMS provider 创建HTTP短信提供商- Parameters:
config- the config | 配置
-
-
Method Details
-
send
Description copied from interface:SmsProviderSend single SMS 发送单条短信- Specified by:
sendin interfaceSmsProvider- Parameters:
message- the message | 消息- Returns:
- the result | 结果
-
sendBatch
Description copied from interface:SmsProviderSend batch SMS 批量发送短信- Specified by:
sendBatchin interfaceSmsProvider- Parameters:
messages- the messages | 消息列表- Returns:
- the results | 结果列表
-
buildRequestBody
Build request body 构建请求体- Parameters:
message- the message | 消息- Returns:
- the request body | 请求体
-
buildAuthHeaders
-
parseResponse
-
getName
Description copied from interface:SmsProviderGet provider name 获取提供商名称- Specified by:
getNamein interfaceSmsProvider- Returns:
- the name | 名称
-
isAvailable
public boolean isAvailable()Description copied from interface:SmsProviderCheck if provider is available 检查提供商是否可用- Specified by:
isAvailablein interfaceSmsProvider- Returns:
- true if available | 如果可用返回true
-
getConfig
-
getHttpClient
-