1'
This commit is contained in:
@@ -2,7 +2,6 @@ package uuptapi
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
@@ -25,8 +24,7 @@ const (
|
||||
)
|
||||
|
||||
func (a *API) MakeUURequestHead() map[string]interface{} {
|
||||
requestParam := make(map[string]interface{}, 5)
|
||||
requestParam["sign"] = a.sign
|
||||
requestParam := make(map[string]interface{}, 4)
|
||||
requestParam["timestamp"] = utils.Int64ToStr(time.Now().Unix())
|
||||
requestParam["nonce_str"] = randStr()
|
||||
requestParam["openid"] = a.openid
|
||||
@@ -80,22 +78,22 @@ func (a *API) signParam(params map[string]interface{}) (sign string) {
|
||||
func (a *API) AccessAPI(baseUrl, actionApi, method string, bizParams map[string]interface{}) (retVal map[string]interface{}, err error) {
|
||||
bizParams["sign"] = a.signParam(bizParams)
|
||||
//序列化
|
||||
data, err := json.Marshal(bizParams)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
//data, err := json.Marshal(bizParams)
|
||||
//if err != nil {
|
||||
// return nil, err
|
||||
//}
|
||||
//完整请求url
|
||||
fullPath := utils.GenerateGetURL(baseUrl, actionApi, nil)
|
||||
//发送请求
|
||||
sendUrl := func() *http.Request {
|
||||
var request *http.Request
|
||||
if method == RequestPost {
|
||||
request, _ = http.NewRequest(http.MethodPost, fullPath, strings.NewReader(string(data)))
|
||||
//request, _ = http.NewRequest(http.MethodPost, fullPath, strings.NewReader(string(data)))
|
||||
request, _ = http.NewRequest(http.MethodPost, fullPath, strings.NewReader(utils.Map2URLValues(bizParams).Encode()))
|
||||
} else {
|
||||
request, _ = http.NewRequest(http.MethodGet, utils.GenerateGetURL(baseUrl, actionApi, bizParams), nil)
|
||||
}
|
||||
//request.Header.Set("Content-Type", "form-data")
|
||||
request.Header.Set("Content-Type", "multipart/form-data")
|
||||
request.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||
return request
|
||||
}
|
||||
//数据解析
|
||||
|
||||
Reference in New Issue
Block a user