修签名
This commit is contained in:
@@ -51,7 +51,6 @@ func New(appID, appSecret, merchantId, code string, config ...*platformapi.APICo
|
||||
appID: appID,
|
||||
merchantId: merchantId,
|
||||
signature: "",
|
||||
timestamp: time.Now().Unix() * 1000,
|
||||
accessToken: "",
|
||||
version: "1.0",
|
||||
appSecret: appSecret,
|
||||
@@ -78,9 +77,8 @@ func (a *API) signParam(params map[string]interface{}) (sig string) {
|
||||
}
|
||||
|
||||
func (a *API) AccessAPI(baseUrl, actionApi, method string, bizParams map[string]interface{}) (retVal map[string]interface{}, err error) {
|
||||
if a.signature == "" {
|
||||
a.signature = a.signParam(bizParams)
|
||||
}
|
||||
bizParams["timestamp"] = utils.Int64ToStr(time.Now().Unix() * 1000)
|
||||
bizParams["signature"] = a.signParam(bizParams)
|
||||
// 序列化
|
||||
data, err := json.Marshal(bizParams)
|
||||
if err != nil {
|
||||
@@ -130,7 +128,6 @@ func (a *API) GetAccessToken() (tokenInfo *TokenInfo, err error) {
|
||||
parameter["code"] = a.code
|
||||
parameter["app_id"] = a.appID
|
||||
parameter["merchant_id"] = a.merchantId
|
||||
parameter["timestamp"] = utils.Int64ToStr(a.timestamp)
|
||||
|
||||
result, err := a.AccessAPI(TokenURL, "", RequestPost, parameter)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user