1
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"crypto/md5"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@@ -12,7 +13,6 @@ import (
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -144,7 +144,6 @@ func (a *API) AccessAPI2(cmd string, isGet bool, bizParams map[string]interface{
|
||||
}
|
||||
signURL := a.genURL(cmd) + "?"
|
||||
params[signKey] = a.signParams(signURL, params)
|
||||
//globals.SugarLogger.Debugf("params[signKey]=============%s", params[signKey])
|
||||
err = platformapi.AccessPlatformAPIWithRetry(a.client,
|
||||
func() *http.Request {
|
||||
var request *http.Request
|
||||
@@ -154,7 +153,6 @@ func (a *API) AccessAPI2(cmd string, isGet bool, bizParams map[string]interface{
|
||||
request, _ = http.NewRequest(http.MethodGet, fullURL, nil)
|
||||
} else {
|
||||
fullURL := a.genURL(cmd)
|
||||
// baseapi.SugarLogger.Debug(utils.Map2URLValues(params).Encode())
|
||||
if imgData == nil {
|
||||
request, _ = http.NewRequest(http.MethodPost, fullURL, strings.NewReader(utils.Map2URLValues(params).Encode()))
|
||||
request.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||
@@ -167,11 +165,9 @@ func (a *API) AccessAPI2(cmd string, isGet bool, bizParams map[string]interface{
|
||||
fw.Write(imgData.([]byte))
|
||||
}
|
||||
for k, v := range params {
|
||||
// baseapi.SugarLogger.Debug(k, " ", v)
|
||||
w.WriteField(k, url.QueryEscape(fmt.Sprint(v)))
|
||||
}
|
||||
w.Close()
|
||||
// b.WriteString(utils.Map2URLValues(params).Encode())
|
||||
request, _ = http.NewRequest(http.MethodPost, fullURL, &b)
|
||||
request.Header.Set("Content-Type", w.FormDataContentType())
|
||||
}
|
||||
@@ -225,17 +221,14 @@ func (a *API) AccessAPI3(cmd string, isGet bool, bizParams map[string]interface{
|
||||
params = utils.MergeMaps(params, bizParams)
|
||||
signURL := a.genURL(cmd) + "?"
|
||||
params[signKey] = a.signParams(signURL, params)
|
||||
//globals.SugarLogger.Debugf("params[signKey]=============%s", params[signKey])
|
||||
err = platformapi.AccessPlatformAPIWithRetry(a.client,
|
||||
func() *http.Request {
|
||||
var request *http.Request
|
||||
if isGet {
|
||||
fullURL := utils.GenerateGetURL(apiURL, cmd, params)
|
||||
// baseapi.SugarLogger.Debug(fullURL)
|
||||
request, _ = http.NewRequest(http.MethodGet, fullURL, nil)
|
||||
} else {
|
||||
fullURL := a.genURL(cmd)
|
||||
// baseapi.SugarLogger.Debug(utils.Map2URLValues(params).Encode())
|
||||
request, _ = http.NewRequest(http.MethodPost, fullURL, strings.NewReader(utils.Map2URLValues(params).Encode()))
|
||||
request.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||
request.Header.Set("charset", "UTF-8")
|
||||
|
||||
Reference in New Issue
Block a user