This commit is contained in:
suyl
2021-08-02 11:13:10 +08:00
parent e6ea1adef7
commit 6f5644325d
12 changed files with 151 additions and 17 deletions

View File

@@ -110,7 +110,7 @@ func method2ResponseKey(method string) (responseKey string) {
return responseKey
}
func (a *API) AccessAPI(method string, params, bizContent map[string]interface{}) (retVal map[string]interface{}, err error) {
func (a *API) AccessAPI(method string, params, bizContent map[string]interface{}, isPost bool) (retVal map[string]interface{}, err error) {
params = utils.MergeMaps(map[string]interface{}{
"app_id": a.GetAppID(),
"method": method,
@@ -126,11 +126,16 @@ func (a *API) AccessAPI(method string, params, bizContent map[string]interface{}
err = platformapi.AccessPlatformAPIWithRetry(a.client,
func() *http.Request {
var request *http.Request
params["timestamp"] = utils.GetCurTimeStr()
params[signKey] = a.signParams(params)
fullURL := utils.GenerateGetURL(prodURL, "", params)
request, _ := http.NewRequest(http.MethodGet, fullURL, nil)
// request, _ := http.NewRequest(http.MethodPost, prodURL, bytes.NewReader(utils.MustMarshal(params)))
if isPost {
request, _ = http.NewRequest(http.MethodPost, prodURL, strings.NewReader(utils.Map2URLValues(params).Encode()))
} else {
request, _ = http.NewRequest(http.MethodGet, fullURL, nil)
}
return request
},
a.config,