Skip to content

Commit

Permalink
修复Server酱推送失败问题
Browse files Browse the repository at this point in the history
  • Loading branch information
ztino committed Jan 6, 2021
1 parent a99588e commit fb2be80
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions service/wechat.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/tidwall/gjson"
"github.com/unknwon/goconfig"
"github.com/ztino/jd_seckill/log"
"net/http"
)

type Wechat struct {
Expand All @@ -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())
Expand Down

0 comments on commit fb2be80

Please sign in to comment.