1 Star 0 Fork 0

kzangv/gsf-fof

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
multixsend.go 1.83 KB
Copy Edit Raw Blame History
kzangv authored 2023-02-23 13:34 . fixed
package sms
import "encoding/json"
type multixsend struct {
appid string
appkey string
signType string
project string
multi []map[string]interface{}
tag string
}
const multixsendURL = Server + "/message/multixsend"
type multi struct {
to string
vars map[string]string
}
func CreateMulti() *multi {
return &multi{"", make(map[string]string)}
}
func (m *multi) SetTo(to string) *multi {
m.to = to
return m
}
func (m *multi) AddVar(key string, val string) *multi {
m.vars[key] = val
return m
}
func (m *multi) AddVars(data map[string]string) *multi {
for k, v := range data {
m.AddVar(k, v)
}
return m
}
func (m *multi) Get() map[string]interface{} {
item := make(map[string]interface{})
item["to"] = m.to
item["vars"] = m.vars
return item
}
func CreateMultiXsend(config map[string]string) *multixsend {
return &multixsend{config["appid"], config["appkey"], config["signType"], "", nil, ""}
}
func (m *multixsend) SetProject(project string) *multixsend {
m.project = project
return m
}
func (m *multixsend) AddMulti(multi map[string]interface{}) *multixsend {
m.multi = append(m.multi, multi)
return m
}
func (m *multixsend) SetTag(tag string) *multixsend {
m.tag = tag
return m
}
func (m *multixsend) MultiXsend() string {
config := make(map[string]string)
config["appid"] = m.appid
config["appkey"] = m.appkey
config["signType"] = m.signType
req := make(map[string]string)
req["appid"] = m.appid
req["project"] = m.project
if m.signType != "normal" {
req["sign_type"] = m.signType
req["timestamp"] = _GetTimestamp()
req["sign_version"] = "2"
}
if m.tag != "" {
req["tag"] = m.tag
}
req["signature"] = _CreateSignature(req, config)
//v2 数字签名 multi 不参与计算
data, err := json.Marshal(m.multi)
if err == nil {
req["multi"] = string(data)
}
return _Post(multixsendURL, req)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/kzangv/gsf-fof.git
git@gitee.com:kzangv/gsf-fof.git
kzangv
gsf-fof
gsf-fof
v0.4.2

Search