This commit is contained in:
richboo111
2022-12-06 17:38:11 +08:00
2 changed files with 7 additions and 3 deletions

View File

@@ -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))
}

View File

@@ -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