Verified Commit a8ab6db3 authored by Cui's avatar Cui

fix bug

parent 3e52700c
......@@ -13,6 +13,12 @@ const (
SMSSendUri = "https://yun.tim.qq.com/v5/tlssmssvr/sendsms"
)
type SmsResponse struct {
Result int `json:"result"`
Errmsg string `json:"errmsg"`
Ext string `json:"ext"`
}
func SmsMessageSender(sm SmsMessage, appId int, appKey string) (int, string) {
log := Logger.WithFields(logrus.Fields{
"position": "sms.go",
......@@ -34,15 +40,22 @@ func SmsMessageSender(sm SmsMessage, appId int, appKey string) (int, string) {
body, statusCode, err := FasthttpPost(uri, reqBody)
if err != nil {
var res SmsResponse
var errorStr string
_ = json.Unmarshal(body, &res)
if err != nil || res.Result != 0 {
log.
WithField("error", err).
Error("SmsMessageSender Error!")
statusCode = -1
errorStr = "SmsMessageSender Error -" + err.Error()
} else {
log.
WithFields(sm.ToFields()).
WithField("response", string(body)).
Info("SmsMessageSender send success !")
}
return statusCode, ""
return statusCode, errorStr
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment