submail

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: MIT Imports: 10 Imported by: 0

README

Submail

对接短信服务提供商 SUBMAIL 开放接口!

下载

go get github.com/Carrotxyy/submail-sdk

实例

func main(){
	// 密钥明文验证模式
	core := submail.NewSubmail("appid", "appkey")
   	// 数字签名验证模式 
   	//core := submail.NewSubmail(
	//	"appid",
	//	"appkey",
	//	submail.WithSignType(submail.MD5),
	//	submail.WithSignVersion(submail.Version2),
	//)

	// 创建 SMS
	smsCli := sms.NewSMS(core)

	// 创建消息体
	vars := map[string]string{
		"name": "肖二阳",
		"time": "2022/04/28 12:00:00",
	}
	request := sms.NewXSendRequest("phone number", "template id", vars)

	// 发送模板消息
	err, response := smsCli.XSend(context.TODO(), request)
	if err != nil {
		fmt.Println(err)
		return
	}
	if response.Code != submail.SUCCESS {
		fmt.Println(response)
		return
	}
}

Documentation

Overview

*

  • @Author: Jacky
  • @Description:
  • @File: auth
  • @Version: 1.0.0
  • @Date: 2022/4/27 14:40

*

  • @Author: Jacky
  • @Description:
  • @File: errcode
  • @Version: 1.0.0
  • @Date: 2022/4/28 16:08

*

  • @Author: Jacky
  • @Description:
  • @File: submail
  • @Version: 1.0.0
  • @Date: 2022/4/27 10:52

*

  • @Author: Jacky
  • @Description:
  • @File: utils
  • @Version: 1.0.0
  • @Date: 2022/4/27 15:48

Index

Constants

View Source
const (
	MD5    SignType = "md5"
	SHA1   SignType = "sha1"
	Normal SignType = "normal"

	Version1 SignVersion = "1"
	Version2 SignVersion = "2"
)
View Source
const (
	SUCCESS int = 0 // 请求成功
)

Variables

This section is empty.

Functions

func JsonContentType

func JsonContentType() (string, string)

func JsonMarshal

func JsonMarshal(v interface{}) string

func SortAndJoin

func SortAndJoin(data map[string]string, sep string) string

Types

type Message

type Message interface {
	SignMeta() string                  // 返回签名元数据
	SetAppID(appID string)             // 设置 appid
	SetTag(tag string)                 // 设置 tag
	SetTimestamp(timestamp string)     // 设置时间戳
	SetSignType(signType string)       // 设置 api 授权模式
	SetSignVersion(signVersion string) // 设置加密计算方式
	SetSignature(signature string)     // 设置签名
}

type Option

type Option func(c *config)

func WithSignType

func WithSignType(signType SignType) Option

func WithSignVersion

func WithSignVersion(signVersion SignVersion) Option

func WithTag

func WithTag(tag string) Option

type SignType

type SignType string

type SignVersion

type SignVersion string

func (SignVersion) Is

func (v SignVersion) Is(version string) bool

type Submail

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

func NewSubmail

func NewSubmail(appid string, appkey string, options ...Option) *Submail

func (*Submail) Client

func (s *Submail) Client() *resty.Request

func (*Submail) Sign

func (s *Submail) Sign(message Message)

Directories

Path Synopsis
*
*

Jump to

Keyboard shortcuts

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