Fetch the repository succeeded.
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)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。