meituan-union平台api对接
This commit is contained in:
parent
1e5037d017
commit
ccfc4e154b
@ -31,10 +31,11 @@ func newMeituanCsrApiImpl(log logx.Logger, client *Client) MeituanCsrApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *meituanCsrApiImpl) GetLink(params PromotionLinkRequest) (*PromotionLinkResponse, error) {
|
func (a *meituanCsrApiImpl) GetLink(params PromotionLinkRequest) (*PromotionLinkResponse, error) {
|
||||||
|
url := a.Url(context.Background(), GetLinkUrl)
|
||||||
queryArgs := util.StructToMap(params)
|
queryArgs := util.StructToMap(params)
|
||||||
req := &client.HttpRequest{Headers: a.client.Headers, QueryArgs: queryArgs}
|
req := &client.HttpRequest{Headers: a.client.Headers, QueryArgs: queryArgs}
|
||||||
response := new(PromotionLinkResponse)
|
response := new(PromotionLinkResponse)
|
||||||
if err := a.client.HttpGet(GetLinkUrl, req, &client.HttpResponse{Result: response}); err != nil {
|
if err := a.client.HttpGet(url, req, &client.HttpResponse{Result: response}); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return response, nil
|
return response, nil
|
||||||
@ -58,6 +59,6 @@ func (a *meituanCsrApiImpl) sign(params map[string]any) string {
|
|||||||
func (a *meituanCsrApiImpl) generateAccessToken(ts int64) string {
|
func (a *meituanCsrApiImpl) generateAccessToken(ts int64) string {
|
||||||
//Access_token生成规则
|
//Access_token生成规则
|
||||||
//将媒体utmSource与时间戳(秒)拼接起来,然后使用AES加密生成。例如:utmSource为1000,时间戳1555510603,则access_token为AesEncode(10001555510603),每个token有效期为1小时
|
//将媒体utmSource与时间戳(秒)拼接起来,然后使用AES加密生成。例如:utmSource为1000,时间戳1555510603,则access_token为AesEncode(10001555510603),每个token有效期为1小时
|
||||||
encodeStr, _ := a.client.authConfig.aes.Encode(fmt.Sprintf("%s%d", a.client.authConfig.UtmSource, ts))
|
encodeStr, _ := a.client.aes.Encode(fmt.Sprintf("%s%d", a.client.authConfig.UtmSource, ts))
|
||||||
return encodeStr
|
return encodeStr
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,6 @@ import (
|
|||||||
type AuthConfig struct {
|
type AuthConfig struct {
|
||||||
AppKey string
|
AppKey string
|
||||||
UtmSource string
|
UtmSource string
|
||||||
aes *AES
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 连接第三方平台的client
|
// 连接第三方平台的client
|
||||||
@ -18,6 +17,7 @@ type Client struct {
|
|||||||
client.ThirdClient
|
client.ThirdClient
|
||||||
log logx.Logger
|
log logx.Logger
|
||||||
authConfig AuthConfig
|
authConfig AuthConfig
|
||||||
|
aes *AES
|
||||||
Headers map[string]string
|
Headers map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,6 +26,7 @@ func newClient(log logx.Logger, conf AuthConfig) *Client {
|
|||||||
ThirdClient: client.NewThirdClient(log),
|
ThirdClient: client.NewThirdClient(log),
|
||||||
log: log,
|
log: log,
|
||||||
authConfig: conf,
|
authConfig: conf,
|
||||||
|
aes: NewAes(conf.AppKey),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user