v4

package
v0.0.0-...-07ef6c8 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2023 License: Artistic-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MaxBatchCount             int = 100
	SingleSendRequestBodyPool sync.Pool
)

Functions

func HmacSha256AndBase64

func HmacSha256AndBase64(b1 []byte, b2 []byte, spKeyByte []byte) string

这里golang跟java有区别,不能直接拼接字符串然后转化成[]byte。必须用下面的方法 参考https://stackoverflow.com/questions/51259453/hmacsha256-signature-generated-is-different-in-java-than-in-go

func ReleaseSingleSendRequestBody

func ReleaseSingleSendRequestBody(sb *SingleSendRequestBody)

Types

type ActiveFetchRequestBody

type ActiveFetchRequestBody struct {
	//可选 默认500,支持范围[10, 1000],参数超出范围按照默认算
	MaxSize int `json:"maxSize"`
}

type BatchSendItemResponseBody

type BatchSendItemResponseBody struct {
	Status int    `json:"status"`
	MsgId  string `json:"msgid"`
}

type BatchSendItemReuqestBody

type BatchSendItemReuqestBody struct {
	//必须。最大长度1005。短信内容,例如: 【线上线下】您的验证码为123456,在10分钟内有效。
	Content string `json:"content"`
	//必须。多个号码用,分隔开,号码数量<=10000
	Mobile string `json:"mobile"`
	//可选。可选。扩展码,必须可解析为数字,最大长度12
	ExtCode string `json:"extCode"`
	//自定义msgId,若不传,由我们平台生成一个msgId返回,若设置此值,平台将使用此msgId作为此次提交的唯一编号并返回此msgId
	MsgId string `json:"msgid"`
}

短信群发,单条短信的结构

type BatchSendResponseBody

type BatchSendResponseBody struct {
	Status int                          `json:"status"`
	Result []*BatchSendItemResponseBody `json:"result"`
}

type DailyStatsRequestBody

type DailyStatsRequestBody struct {
	//必选,最大长度8,日期格式化:yyyyMMdd 示例: 20200101
	Date string `json:"date"`
}

type SingleSendRequestBody

type SingleSendRequestBody struct {
	//必须。最大长度1005。短信内容,例如: 【线上线下】您的验证码为123456,在10分钟内有效。
	Content string `json:"content"`
	//必须。多个号码用,分隔开,号码数量<=10000
	Mobile string `json:"mobile"`
	//可选。可选。扩展码,必须可解析为数字,最大长度12
	ExtCode string `json:"extCode"`
	//可选。最大长度64。批次号,可用于客户侧按照批次号对短信进行分组
	SId string `json:"sId"`
}

短信单发

func AcquireSingleSendRequestBody

func AcquireSingleSendRequestBody() *SingleSendRequestBody

func (*SingleSendRequestBody) Reset

func (s *SingleSendRequestBody) Reset()

type SmsSigner

type SmsSigner struct {
	//我方提供的发送账号的唯一标识
	SpId string `json:"spId"`
	//共享spKey密钥
	SpKey string `json:"spKey"`
	//SmsSendUrl 我方提供的短信发送Url地址,例如https://api-hw.onmsg.cn
	SmsSendUrl string `json:"BaseUrl"`
	//平台支持客户主动来获取短信的状态报告,我方提供主动获取短信报告的接口
	SmsReportUrl string `json:"reportUrl"`
}

func NewSmsSigner

func NewSmsSigner(spId, spKey, smsSendUrl, reportUrl string) *SmsSigner

func (*SmsSigner) FetchStatus

func (ss *SmsSigner) FetchStatus() ([]*StatusResultSingleItem, int64, error)

func (*SmsSigner) FetchUpstream

func (ss *SmsSigner) FetchUpstream() ([]*UpstreamItem, int64, error)

func (*SmsSigner) Send

func (ss *SmsSigner) Send(b []byte, url string) ([]byte, error)

func (*SmsSigner) SendMultiSms

func (ss *SmsSigner) SendMultiSms(smsItems []*BatchSendItemReuqestBody) ([]string, []string, int64, error)

成功MESSAGEid列表 ,失败message id 列表,失败

func (*SmsSigner) SendSingleSms

func (ss *SmsSigner) SendSingleSms(content string, mobile string, extcode string, sid string) (string, error)
type SingleSendRequestBody struct {
	//必须。最大长度1005。短信内容,例如: 【线上线下】您的验证码为123456,在10分钟内有效。
	Content string `json:"content"`
	//必须。多个号码用,分隔开,号码数量<=10000
	Mobile string `json:"mobile"`
	//可选。可选。扩展码,必须可解析为数字,最大长度12
	ExtCode string `json:"extCode"`
	//可选。最大长度64。批次号,可用于客户侧按照批次号对短信进行分组
	SId string `json:"sId"`
}

func (*SmsSigner) Sign

func (ss *SmsSigner) Sign(r *http.Request, jsonByte []byte)

func (*SmsSigner) SignAgain

func (ss *SmsSigner) SignAgain(jsonByte []byte)

func (*SmsSigner) SignWithTimeAgain

func (ss *SmsSigner) SignWithTimeAgain(jsonByte []byte, timeStamp string)

type StatusResultResponseBody

type StatusResultResponseBody struct {
	Status int                       `json:"status"`
	Result []*StatusResultSingleItem `json:"result"`
}
{
    "status" : 0,                                 // 固定值0
    "result" :
    [
        {
            "phone" : "13921350591",             // 手机号码
            "msgid" : "-8629637681836384963",    // 与提交中的msgid 一致
            "status" : "DELIVRD" ,               // 短信状态,参考附表2
            "donetime" : "20170816153922",       // 短信到达时间
			"fee" : 2,                           // 短信计费条数
			"sId" : "123456789abcdefg"           // 批次号
        }
        //这里是数组会有多条,默认最大500条

,平台可配置

    ]
}

type StatusResultSingleItem

type StatusResultSingleItem struct {
	Phone    string `json:"phone"`
	MsgId    string `json:"msgid"`
	Status   string `json:"status"`
	DoneTime string `json:"donetime"`
	Fee      int    `json:"fee"`
	SId      string `json:"s_id"`
}

type UpstreamItem

type UpstreamItem struct {
	Phone       string `json:"phone"`
	ExtCode     string `json:"extCode"`
	Content     string `json:"content"`
	ReceiveTime string `json:"receivetime"`
	MsgId       string `json:"msgid"`
	Sign        string `json:"sign"`
}

type UpstreamItemResponseBody

type UpstreamItemResponseBody struct {
	Status int             `json:"status"`
	Result []*UpstreamItem `json:"result"`
}

Jump to

Keyboard shortcuts

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