From 677572a3bd443e6b885b9919f1c93f5aa946953a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Tue, 6 Dec 2022 14:09:27 +0800 Subject: [PATCH] 1 --- platformapi/weixinapi/sns.go | 7 ++++--- platformapi/weixinapi/weixinapi.go | 3 +++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/platformapi/weixinapi/sns.go b/platformapi/weixinapi/sns.go index dd69fb92..4fb3afc1 100644 --- a/platformapi/weixinapi/sns.go +++ b/platformapi/weixinapi/sns.go @@ -188,8 +188,8 @@ func (a *API) MiniProgramSortLink() (string, error) { bodyJson := map[string]interface{}{ //"access_token ": weChatToken, - "expire_type ": 1, - "expire_time": 1, + "expire_type": 1, + "expire_interval": 1, } body, _ := json.Marshal(bodyJson) result, err := a.AccessAPI("wxa/generate_urllink", parmaJson, string(body)) @@ -197,7 +197,8 @@ func (a *API) MiniProgramSortLink() (string, error) { return "", err } - if result["errcode"] != 0 { + errCode, _ := result["errcode"].(json.Number).Int64() + if errCode != 0 { return "", errors.New(result["errmsg"].(string)) } diff --git a/platformapi/weixinapi/weixinapi.go b/platformapi/weixinapi/weixinapi.go index 568602fe..745a0f51 100644 --- a/platformapi/weixinapi/weixinapi.go +++ b/platformapi/weixinapi/weixinapi.go @@ -102,6 +102,9 @@ func (a *API) AccessAPI(action string, params map[string]interface{}, body strin request, _ = http.NewRequest(http.MethodGet, fullURL, nil) } else { request, _ = http.NewRequest(http.MethodPost, fullURL, strings.NewReader(body)) + if strings.Contains(fullURL, "wxa/generate_urllink") { + request.Header.Set("Content-Type", "application/json") + } } request.Close = true // todo try to fix EOF error when accessing weixin api. return request