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