diff --git a/service/wechat.go b/service/wechat.go index 986c82b..7b60f9b 100644 --- a/service/wechat.go +++ b/service/wechat.go @@ -7,7 +7,6 @@ import ( "github.com/tidwall/gjson" "github.com/unknwon/goconfig" "github.com/ztino/jd_seckill/log" - "net/http" ) type Wechat struct { @@ -23,11 +22,7 @@ func (this *Wechat) Send(title,msg string) error { req:=httpc.NewRequest(client) url:=fmt.Sprintf("http://sc.ftqq.com/%s.send",this.conf.MustValue("messenger","server_chan_sckey","")) req.SetHeader("User-Agent","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36") - resp,body,err:=req.SetUrl(url+"?text="+title+"&desp="+msg).SetMethod("get").Send().End() - if err!=nil || resp.StatusCode!=http.StatusOK { - log.Println("微信推送失败,网络错误") - return errors.New("微信推送失败,网络错误") - } + _,body,_:=req.SetUrl(url+"?text="+title+"&desp="+msg).SetMethod("get").Send().End() if gjson.Get(body,"errno").Int()!=0 { log.Println("微信推送失败,返回错误:"+gjson.Get(body,"errmsg").String()) return errors.New("微信推送失败,返回错误:"+gjson.Get(body,"errmsg").String())