sms

package
v0.0.0-...-3d0adf2 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

====================================================

# Copyright (C)2019 All rights reserved. # # Author : domchan # Email : 814172254@qq.com # File Name : config.go # Created : 2019/1/7 15:24 # Last Modified : 2019/1/7 15:24 # Describe : # # ====================================================

====================================================

# Copyright (C)2019 All rights reserved. # # Author : domchan # Email : 814172254@qq.com # File Name : request.go # Created : 2019/1/7 16:06 # Last Modified : 2019/1/7 16:06 # Describe : # # ====================================================

====================================================

# Copyright (C)2019 All rights reserved. # # Author : domchan # Email : 814172254@qq.com # File Name : response.go # Created : 2019/1/7 15:50 # Last Modified : 2019/1/7 15:50 # Describe : # # ====================================================

====================================================

# Copyright (C)2019 All rights reserved. # # Author : domchan # Email : 814172254@qq.com # File Name : send.go # Created : 2019/1/7 14:33 # Last Modified : 2019/1/7 14:33 # Describe : # # ====================================================

Index

Constants

View Source
const ResponseCodeOk = "OK"

The response code which stands for a sms is sent successfully.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client 发送短信客户端,implements send.Sender

func NewClient

func NewClient(cfg Config) *Client

func (*Client) Send

func (c *Client) Send(msg send.Message, do send.DoRes) error

Send 发送短信,msg需要使用sms.NewRequest(...)生成 可以使用do将请求结果回传,也可以传nil忽略结果

type Config

type Config struct {
	AccessKeyId  string
	AccessSecret string
	GatewayURL   string
}

type Request

type Request struct {
	// system parameters
	AccessKeyId      string
	Timestamp        string
	Format           string
	SignatureMethod  string
	SignatureVersion string
	SignatureNonce   string
	Signature        string

	// business parameters
	Action          string
	Version         string
	RegionId        string
	PhoneNumbers    string
	SignName        string
	TemplateCode    string
	TemplateParam   string
	SmsUpExtendCode string
	OutId           string
}

Request implements send.Message

func NewRequest

func NewRequest(phoneNumbers, signName, templateCode, templateParam, outID string) *Request

NewRequest implements send.Message,这里没有赋值AccessKeyId, 而是在send的时候才赋的该值,如果需要单独使用,请记得给该值赋值

func (*Request) Content

func (r *Request) Content() []byte

func (*Request) Encode

func (r *Request) Encode(accessKeySecret, gatewayUrl string) (string, error)

func (*Request) To

func (r *Request) To() string

type Response

type Response struct {
	// The raw response from server.
	RawResponse []byte `json:"-"`
	/* Response body */
	RequestId string `json:"RequestId"`
	Code      string `json:"Code"`
	Message   string `json:"Message"`
	BizId     string `json:"BizId"`
}

@see https://help.aliyun.com/document_detail/55284.html#出参列表 The Response of sending sms API.

func (*Response) IsSuccessful

func (m *Response) IsSuccessful() bool

Jump to

Keyboard shortcuts

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