1 Star 0 Fork 0

kzangv/gsf-fof

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
multixsend.go 1.83 KB
一键复制 编辑 原始数据 按行查看 历史
kzangv 提交于 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.2.0

搜索帮助

0d507c66 1850385 C8b1a773 1850385