tencent

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 4, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	SendSms(msg *Message, telephones ...string) ([]FailedInfo, error)
}

func NewClient

func NewClient(config Config) (Client, error)

NewClient 实例化一个认证客户端,入参需要传入腾讯云账户密钥对secretId,secretKey

type Config

type Config struct {
	SecretId  string `json:"secret_id"`
	SecretKey string `json:"secret_key"`
	// Region 地域信息,可以直接填写字符串ap-guangzhou,或者引用预设的常量
	Region string `json:"region"`
	// HttpProfile 客户端配置对象,可以指定超时时间等配置
	HttpProfile *HttpProfile `json:"http_profile"`
	/* SignMethod SDK默认用TC3-HMAC-SHA256进行签名,非必要请不要修改这个字段 */
	SignMethod string `json:"sign_method"`
}

type FailedInfo

type FailedInfo struct {
	Telephone string `json:"telephone"`
	Message   string `json:"message"`
}

FailedInfo 发送失败的短信信息

type HttpProfile

type HttpProfile struct {
	/*
	   ReqMethod
	   SDK默认使用POST方法。
	 * 如果你一定要使用GET方法,可以在这里设置。GET方法无法处理一些较大的请求 */
	ReqMethod string `json:"req_method"`
	/*
	   ReqTimeout
	   SDK有默认的超时时间,非必要请不要进行调整
	 * 如有需要请在代码中查阅以获取最新的默认值 */
	ReqTimeout int `json:"req_timeout"`
	/*
	   Endpoint
	   SDK会自动指定域名。通常是不需要特地指定域名的,但是如果你访问的是金融区的服务
	 * 则必须手动指定域名,例如sms的上海金融区域名: sms.ap-shanghai-fsi.tencentcloudapi.com */
	Endpoint string `json:"endpoint"`
}

type Message

type Message struct {
	//SmsSdkAppId 短信应用ID: 短信SdkAppId在 [短信控制台] 添加应用后生成的实际SdkAppId,示例如1400006666
	SmsSdkAppId string `json:"sms_sdk_app_id"`
	// SignName 短信签名内容: 使用 UTF-8 编码,必须填写已审核通过的签名,签名信息可登录 [短信控制台] 查看
	SignName string `json:"sign_name"`
	// TemplateId 模板 ID: 必须填写已审核通过的模板 ID。模板ID可登录 [短信控制台] 查
	TemplateId string `json:"template_id"`
	// TemplateParamSet 模板参数: 若无模板参数,则设置为空
	TemplateParamSet []string `json:"template_param_set"`
	// ExtendCode 短信码号扩展号: 默认未开通,如需开通请联系 [sms helper]
	ExtendCode string `json:"extend_code"`
	// SessionContext 用户的 session 内容: 可以携带用户侧 ID 等上下文信息,server 会原样返回
	SessionContext string `json:"session_context"`
	// SenderId 国际/港澳台短信 SenderId: 国内短信填空,默认未开通,如需开通请联系 [sms helper]
	SenderId string `json:"sender_id"`
}

func NewMessage

func NewMessage() *Message

func (*Message) WithAppId

func (msg *Message) WithAppId(appId string) *Message

func (*Message) WithExtendCode

func (msg *Message) WithExtendCode(extendCode string) *Message

func (*Message) WithSenderId

func (msg *Message) WithSenderId(senderId string) *Message

func (*Message) WithSessionContext

func (msg *Message) WithSessionContext(sessionContext string) *Message

func (*Message) WithSignName

func (msg *Message) WithSignName(sign string) *Message

func (*Message) WithTemplate

func (msg *Message) WithTemplate(id string, params ...int) *Message

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL