Browse Source

抖音团长

master
huangjiajun 5 months ago
parent
commit
e197a1ca87
1 changed files with 52 additions and 0 deletions
  1. +52
    -0
      sms/api.go

+ 52
- 0
sms/api.go View File

@@ -134,6 +134,58 @@ func SmsSend(engine *xorm.Engine, args map[string]interface{}) error {
fmt.Println(err)
return nil
}
func SmsSendZy(engine *xorm.Engine, args map[string]interface{}) error {
where := make(map[string]interface{})
param := []string{
"content", //短信内容
"mobile", //号码多个以英文”,”号分割,最大 2000 个
"code", //扩展号 0-9 数字,超过 8 位自动截取前 8 位
"ext", //自定义信息,状态报告时返回,可以为空
}
for _, v := range param {
if args[v] != "" && args[v] != nil {
where[v] = args[v].(string)
}
}
send := ""
var err error
if args["type"] == "mob" { //mob
if args["templateCode"] == "" {
args["templateCode"] = "normal"
}
where = map[string]interface{}{
"appkey": args["smsmsg_key"],
"zone": args["zone"],
"phone": args["mobile"],
"templateCode": args["templateCode"],
}
send, err = SmsMobApiSend(where)
if err != nil {
return err
}
status := gjson.Get(send, "status").Int()
msg := gjson.Get(send, "error").String()
if status == 471 {
return errors.New("发送的ip不在白名单中")
}
if status == 406 {
return errors.New("appkey不存在")
}
if status != 200 {
return errors.New(msg)
}
} else {
send, err = SmsApiSend(engine, "api.v1.sms", where)
if err != nil {
return err
}
success := gjson.Get(send, "code").Int()
if success != 20000 {
return errors.New("发送失败")
}
}
return nil
}

func SmsApiSend(engine *xorm.Engine, method string, args map[string]interface{}) (string, error) {
smsmsgKey := offical.SysCfgByKey(engine, "smsmsg_key")


Loading…
Cancel
Save