From 19e349342cc7667cf1503bfc1d8daf3155bf9b25 Mon Sep 17 00:00:00 2001 From: fcbhank Date: Tue, 17 Aug 2021 21:01:04 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=9C=A8=E6=AF=8F=E6=AC=A1=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E4=B8=AD=E5=88=B7=E6=96=B0token=EF=BC=8C=E7=A1=AE?= =?UTF-8?q?=E4=BF=9Dtoken=E6=9C=89=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go-wecomchan/wecomchan.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/go-wecomchan/wecomchan.go b/go-wecomchan/wecomchan.go index b5a5c6a..7979226 100644 --- a/go-wecomchan/wecomchan.go +++ b/go-wecomchan/wecomchan.go @@ -221,7 +221,6 @@ func InitJsonData(msgType string) JsonData { func main() { // 设置日志内容显示文件名和行号 log.SetFlags(log.LstdFlags | log.Lshortfile) - accessToken := getAccessToken() wecomChan := func(res http.ResponseWriter, req *http.Request) { _ = req.ParseForm() sendkey := req.FormValue("sendkey") @@ -231,6 +230,8 @@ func main() { msgContent := req.FormValue("msg") msgType := req.FormValue("msg_type") log.Println("mes_type=", msgType) + // 刷新token + accessToken := getAccessToken() mediaId := CheckOrUploadMedia(msgType, req, accessToken) log.Println("企业微信上传临时素材接口返回的media_id==>", mediaId) @@ -242,6 +243,8 @@ func main() { postData.Image = Pic{ MediaId: mediaId, } + // 再次刷新token + accessToken = getAccessToken() sendMessageUrl := fmt.Sprintf(SendMessageApi, accessToken) postStatus := PostMsg(postData, sendMessageUrl)