You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
OneAuth/libs/sms_providers/tencent.go

47 lines
1010 B
Go

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package sms_providers
import (
"context"
"fmt"
"github.com/veypi/OneAuth/cfg"
)
// TencentProvider 腾讯云短信服务
type TencentProvider struct {
secretID string
secretKey string
sdkAppID string
signName string
region string
}
// NewTencentProvider 创建腾讯云短信服务
func NewTencentProvider(config cfg.RegionConfig) (SMSProvider, error) {
return &TencentProvider{
secretID: config.Key,
secretKey: config.Secret,
sdkAppID: config.Endpoint,
signName: config.SignName,
region: config.Provider,
}, nil
}
// SendSMS 发送短信
func (p *TencentProvider) SendSMS(ctx context.Context, req *SendSMSRequest) (string, error) {
// 这里应该调用腾讯云SDK为了示例简化处理
// 实际实现需要集成腾讯云SMS SDK
// 模拟发送逻辑
if req.Phone == "" {
return "", fmt.Errorf("phone is empty")
}
return "tencent-message-id-12345", nil
}
// GetName 获取服务商名称
func (p *TencentProvider) GetName() string {
return "tencent"
}