This commit is contained in:
邹宗楠
2023-06-13 16:33:01 +08:00
parent 54812a2ce2
commit 147ce647fe
7 changed files with 180 additions and 6 deletions

View File

@@ -0,0 +1,41 @@
package tao_vegetable
import (
"encoding/json"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/globals"
"topsdk"
"topsdk/ability304"
"topsdk/ability304/request"
)
const (
AppKey = "34402634"
AppSecret = "fda9a7045262e3aa1f26ca508a9be242"
ServerUrl = "https://eco.taobao.com/router/rest"
)
func NewTaoVegetable(appKey, appSecret, serverUrl string) API {
return API{client: topsdk.NewDefaultTopClient(appKey, appSecret, serverUrl, 2000, 2000)}
}
type API struct {
client topsdk.TopClient
}
func (a API) GetStoreToken(code, uuId string) (*StoreTokenInfo, error) {
param := &request.TaobaoTopAuthTokenCreateRequest{
Code: &code,
}
data, err := ability304.NewAbility304(&a.client).TaobaoTopAuthTokenCreate(param)
globals.SugarLogger.Debugf("token := %s", utils.Format4Output(data, false))
if err != nil {
return nil, err
}
var token *StoreTokenInfo
if err := json.Unmarshal([]byte(data.TokenResult), &token); err != nil {
return nil, err
}
return token, err
}