1
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"net/http"
|
||||
"sort"
|
||||
"strings"
|
||||
@@ -77,7 +78,26 @@ func (a *API) GetToken() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// AccessAPI2 发送请求
|
||||
// AccessAPI1 发送请求(支付)
|
||||
func (a *API) AccessAPI1(url string, params map[string]interface{}) (retVal map[string]interface{}, err error) {
|
||||
err = platformapi.AccessPlatformAPIWithRetry(a.client,
|
||||
func() *http.Request {
|
||||
request, _ := http.NewRequest(http.MethodPost, url, strings.NewReader(utils.Map2URLValues(params).Encode()))
|
||||
request.Header.Set("Content-Type", "application/json")
|
||||
return request
|
||||
},
|
||||
a.config,
|
||||
func(response *http.Response, bodyStr string, jsonResult1 map[string]interface{}) (errLevel string, err error) {
|
||||
if jsonResult1 == nil {
|
||||
return platformapi.ErrLevelRecoverableErr, fmt.Errorf("mapData is nil")
|
||||
}
|
||||
retVal = jsonResult1
|
||||
return platformapi.ErrLevelSuccess, nil
|
||||
})
|
||||
return retVal, err
|
||||
}
|
||||
|
||||
// AccessAPI2 发送请求(登录)
|
||||
func (a *API) AccessAPI2(url string, params map[string]interface{}) (retVal map[string]interface{}, err error) {
|
||||
err = platformapi.AccessPlatformAPIWithRetry(a.client,
|
||||
func() *http.Request {
|
||||
@@ -116,9 +136,12 @@ func (a *API) sign(param map[string]interface{}) string {
|
||||
}
|
||||
|
||||
sort.Strings(paramsArr)
|
||||
signParma := make([]string, 0, 0)
|
||||
|
||||
globals.SugarLogger.Debugf("param := %s", utils.Format4Output(param, false))
|
||||
globals.SugarLogger.Debugf("paramsArr := %s", utils.Format4Output(paramsArr, false))
|
||||
signParma := make([]string, len(paramsArr))
|
||||
for k, v := range paramsArr {
|
||||
if utils.IsNil(param[v]) {
|
||||
if !utils.IsNil(param[v]) {
|
||||
signParma[k] = v + "=" + fmt.Sprintf("%v", param[v])
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user