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
xsend.go 1.45 KB
Copy Edit Raw Blame History
kzangv authored 2023-02-23 13:34 . fixed
package sms
import "encoding/json"
type xsend struct {
appid string
appkey string
signType string
to string
project string
vars map[string]string
tag string
}
const xsendURL = Server + "/message/xsend"
func CreateXsend(config map[string]string) *xsend {
return &xsend{config["appid"], config["appkey"], config["signType"], "", "", make(map[string]string), ""}
}
func (m *xsend) SetTo(to string) *xsend {
m.to = to
return m
}
func (m *xsend) SetProject(project string) *xsend {
m.project = project
return m
}
func (m *xsend) AddVar(key string, val string) *xsend {
m.vars[key] = val
return m
}
func (m *xsend) AddVars(data map[string]string) *xsend {
for k, v := range data {
m.AddVar(k, v)
}
return m
}
func (m *xsend) SetTag(tag string) *xsend {
m.tag = tag
return m
}
func (m *xsend) Xsend() 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["to"] = m.to
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 数字签名 vars 不参与计算
if len(m.vars) > 0 {
data, err := json.Marshal(m.vars)
if err == nil {
req["vars"] = string(data)
}
}
return _Post(xsendURL, 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

D67c1975 1850385 1daf7b77 1850385