|
@ -20,9 +20,9 @@ import ( |
|
|
* @mobiles 手机号,多个用逗号隔开 |
|
|
* @mobiles 手机号,多个用逗号隔开 |
|
|
* @content 短信内容 |
|
|
* @content 短信内容 |
|
|
*/ |
|
|
*/ |
|
|
func SendByUms(spCode, appKey, secretKey, mobiles, templateId, content string) (bool, error) { |
|
|
|
|
|
|
|
|
func SendByUms(spCode, appKey, secretKey, mobiles, templateId, content string) (bool, []byte, error) { |
|
|
if spCode == "" || appKey == "" || secretKey == "" || mobiles == "" || templateId == "" || content == "" { |
|
|
if spCode == "" || appKey == "" || secretKey == "" || mobiles == "" || templateId == "" || content == "" { |
|
|
return false, errors.New("参数不全") |
|
|
|
|
|
|
|
|
return false, []byte(""), errors.New("参数不全") |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
api := "https://api.ums86.com/api/sms/send" |
|
|
api := "https://api.ums86.com/api/sms/send" |
|
@ -56,7 +56,7 @@ func SendByUms(spCode, appKey, secretKey, mobiles, templateId, content string) ( |
|
|
|
|
|
|
|
|
if err != nil { |
|
|
if err != nil { |
|
|
log.Println("post err", err) |
|
|
log.Println("post err", err) |
|
|
return false, err |
|
|
|
|
|
|
|
|
return false, reply, err |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var reply_data map[string]interface{} |
|
|
var reply_data map[string]interface{} |
|
@ -65,14 +65,14 @@ func SendByUms(spCode, appKey, secretKey, mobiles, templateId, content string) ( |
|
|
|
|
|
|
|
|
if err != nil { |
|
|
if err != nil { |
|
|
log.Println(string(reply), err) |
|
|
log.Println(string(reply), err) |
|
|
return false, err |
|
|
|
|
|
|
|
|
return false, reply, err |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if helper.ToStr(reply_data["code"]) != "0" { |
|
|
if helper.ToStr(reply_data["code"]) != "0" { |
|
|
return false, errors.New("短信发送失败," + helper.ToStr(reply_data["msg"])) |
|
|
|
|
|
|
|
|
return false, reply, errors.New("短信发送失败," + helper.ToStr(reply_data["msg"])) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return true, nil |
|
|
|
|
|
|
|
|
return true, reply, nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// ums验签
|
|
|
// ums验签
|
|
|