tencent

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: May 3, 2022 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 struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(options ...Option) (*Client, error)

func NewClientWithConfig added in v1.3.0

func NewClientWithConfig(config Config) (*Client, error)

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

func (*Client) Kernel added in v1.3.0

func (client *Client) Kernel() *sms.Client

func (*Client) SendSms

func (client *Client) SendSms(msg *Message, telephones ...string) ([]FailedInfo, error)

SendSms 发送短信 msg: 短信消息体, 包含短信签名和模板等信息, 使用 NewMessage() 生成 telephones: 下发手机号码,采用 E.164 标准,+[国家或地区码][手机号]

  • 示例如:+8613711112222, 其中前面有一个+号 ,86为国家码,13711112222为手机号,最多不要超过200个手机号

type Config

type Config struct {
	SecretId  string `mapstructure:"secret_id" json:"secret_id"`
	SecretKey string `mapstructure:"secret_key" json:"secret_key"`
	// Region 地域信息,可以直接填写字符串ap-guangzhou,或者引用预设的常量
	Region string `mapstructure:"region" json:"region"`
	// HttpProfile 客户端配置对象,可以指定超时时间等配置
	HttpProfile *HttpProfile `mapstructure:"http_profile" json:"http_profile"`
	/* SignMethod SDK默认用TC3-HMAC-SHA256进行签名,非必要请不要修改这个字段 */
	SignMethod string `mapstructure:"sign_method" 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 `mapstructure:"req_method" json:"req_method"`
	/*
	   ReqTimeout
	   SDK有默认的超时时间,非必要请不要进行调整
	 * 如有需要请在代码中查阅以获取最新的默认值 */
	ReqTimeout int `mapstructure:"req_timeout" json:"req_timeout"`
	/*
	   Endpoint
	   SDK会自动指定域名。通常是不需要特地指定域名的,但是如果你访问的是金融区的服务
	 * 则必须手动指定域名,例如sms的上海金融区域名: sms.ap-shanghai-fsi.tencentcloudapi.com */
	Endpoint string `mapstructure:"endpoint" json:"endpoint"`
}

type Message

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

type Option added in v1.3.0

type Option func(config *Config)

func WithHttpProfile added in v1.3.0

func WithHttpProfile(httpProfile HttpProfile) Option

func WithRegion added in v1.3.0

func WithRegion(region string) Option

func WithSecretId added in v1.3.0

func WithSecretId(secretId string) Option

func WithSecretKey added in v1.3.0

func WithSecretKey(secretKey string) Option

func WithSignMethod added in v1.3.0

func WithSignMethod(signMethod string) Option

Jump to

Keyboard shortcuts

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