1
This commit is contained in:
41
platformapi/tao_vegetable/api_token.go
Normal file
41
platformapi/tao_vegetable/api_token.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user