diff --git a/platform/meituan-csr/api.go b/platform/meituan-csr/api.go index 2d24f2d..abdf31b 100644 --- a/platform/meituan-csr/api.go +++ b/platform/meituan-csr/api.go @@ -31,10 +31,11 @@ func newMeituanCsrApiImpl(log logx.Logger, client *Client) MeituanCsrApi { } func (a *meituanCsrApiImpl) GetLink(params PromotionLinkRequest) (*PromotionLinkResponse, error) { + url := a.Url(context.Background(), GetLinkUrl) queryArgs := util.StructToMap(params) req := &client.HttpRequest{Headers: a.client.Headers, QueryArgs: queryArgs} 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 response, nil @@ -58,6 +59,6 @@ func (a *meituanCsrApiImpl) sign(params map[string]any) string { func (a *meituanCsrApiImpl) generateAccessToken(ts int64) string { //Access_token生成规则 //将媒体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 } diff --git a/platform/meituan-csr/client.go b/platform/meituan-csr/client.go index a7a5d78..2f4ac6c 100644 --- a/platform/meituan-csr/client.go +++ b/platform/meituan-csr/client.go @@ -10,7 +10,6 @@ import ( type AuthConfig struct { AppKey string UtmSource string - aes *AES } // 连接第三方平台的client @@ -18,6 +17,7 @@ type Client struct { client.ThirdClient log logx.Logger authConfig AuthConfig + aes *AES Headers map[string]string } @@ -26,6 +26,7 @@ func newClient(log logx.Logger, conf AuthConfig) *Client { ThirdClient: client.NewThirdClient(log), log: log, authConfig: conf, + aes: NewAes(conf.AppKey), } }