1
This commit is contained in:
@@ -27,8 +27,8 @@ const (
|
||||
func (a *API) MakeUURequestHead() map[string]interface{} {
|
||||
requestParam := make(map[string]interface{}, 5)
|
||||
requestParam["sign"] = a.sign
|
||||
requestParam["timestamp"] = a.timestamp
|
||||
requestParam["nonce_str"] = a.noncestr
|
||||
requestParam["timestamp"] = utils.Int64ToStr(time.Now().Unix())
|
||||
requestParam["nonce_str"] = randStr()
|
||||
requestParam["openid"] = a.openid
|
||||
requestParam["appid"] = a.appid
|
||||
return requestParam
|
||||
@@ -54,7 +54,18 @@ func (a *API) signParam(params map[string]interface{}) (sign string) {
|
||||
keyValues := make([]string, 0)
|
||||
for k, v := range params {
|
||||
if k != signKey {
|
||||
if temp := fmt.Sprint(v); temp != "" {
|
||||
temp := fmt.Sprint(v)
|
||||
if k == "goods_weight" && temp == "0" {
|
||||
continue
|
||||
}
|
||||
if k == "shop_id" && temp == "0" {
|
||||
continue
|
||||
}
|
||||
if k == "goods_price" && temp == "0" {
|
||||
continue
|
||||
}
|
||||
|
||||
if temp != "" {
|
||||
keyValues = append(keyValues, k+"="+temp)
|
||||
}
|
||||
}
|
||||
@@ -67,8 +78,6 @@ 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["timestamp"] = utils.Int64ToStr(time.Now().Unix() * 1000)
|
||||
bizParams["nonce_str"] = randStr()
|
||||
bizParams["sign"] = a.signParam(bizParams)
|
||||
//序列化
|
||||
data, err := json.Marshal(bizParams)
|
||||
@@ -86,7 +95,7 @@ func (a *API) AccessAPI(baseUrl, actionApi, method string, bizParams map[string]
|
||||
request, _ = http.NewRequest(http.MethodGet, utils.GenerateGetURL(baseUrl, actionApi, bizParams), nil)
|
||||
}
|
||||
//request.Header.Set("Content-Type", "form-data")
|
||||
request.Header.Set("Content-Type", "application/json")
|
||||
request.Header.Set("Content-Type", "multipart/form-data")
|
||||
return request
|
||||
}
|
||||
//数据解析
|
||||
|
||||
Reference in New Issue
Block a user