diff --git a/platformapi/tiktok_shop/tiktok_api/sku_test.go b/platformapi/tiktok_shop/tiktok_api/sku_test.go index cd0c0ca5..46100216 100644 --- a/platformapi/tiktok_shop/tiktok_api/sku_test.go +++ b/platformapi/tiktok_shop/tiktok_api/sku_test.go @@ -28,7 +28,7 @@ func init() { } func TestCategory(t *testing.T) { - accesstoken := `{"access_token":"a1746210-a8a3-4497-a87b-09d1f10dbb95","expires_in":1665652252,"scope":"SCOPE","shop_id":"","shop_name":"小时达开放平台对 接专用店","refresh_token":"c1cf8d88-0983-4f2a-b969-3746fae6b0cd","authorit y_id":""}` + accesstoken := `{"access_token":"60f530b2-9ab6-4723-b487-c094918f0d21","expires_in":1666257163,"scope":"SCOPE","shop_id":"","shop_name":"小时达开放平台对接专用店","refresh_token":"1220666a-5e88-458c-a8c0-06d949fbbd3f","authority_id":""}` a := New("7136048270014416392", "c397aa9f-3927-47c4-8cfe-4d84e02602e0", accesstoken) data, err := a.GetShopCategory(0) fmt.Println("err=====", err) @@ -36,7 +36,7 @@ func TestCategory(t *testing.T) { } func TestGetCatePropertyV2(t *testing.T) { - data, err := a.GetCatePropertyV2(22531) + data, err := a.GetCatePropertyV2(0) fmt.Println("err=====", err) fmt.Println("data====", data) // 202209281558450102081001701D7B32C5 } diff --git a/platformapi/weixinapi/sns.go b/platformapi/weixinapi/sns.go index 03b8a273..09c4ba45 100644 --- a/platformapi/weixinapi/sns.go +++ b/platformapi/weixinapi/sns.go @@ -2,6 +2,7 @@ package weixinapi import ( "bytes" + "encoding/json" "errors" "git.rosy.net.cn/baseapi/utils" ) @@ -168,6 +169,37 @@ func (a *API) SNSGetUserPhone(jsCode string) (string, error) { return phoneInfo.PhoneInfo.PhoneNumber, nil } +// 获取小程序短连接CBRetrieveToken +func (a *API) MiniProgramSortLink() (string, error) { + weChatToken := "" + if token := a.CBGetToken(); token == "" { + newToken, err := a.CBRetrieveToken() + if err != nil { + return "", err + } + weChatToken = newToken.AccessToken + } + parmaJson := map[string]interface{}{ + "access_token": weChatToken, + } + + bodyJson := map[string]interface{}{ + "access_token ": weChatToken, + "expire_type ": 0, + } + body, _ := json.Marshal(bodyJson) + result, err := a.AccessAPI("wxa/generate_urllink", parmaJson, string(body)) + if err != nil { + return "", err + } + + if result["errcode"] != 0 { + return "", errors.New(result["errmsg"].(string)) + } + + return result["url_link"].(string), nil +} + // 待删除 func (a *API) SNSDecodeMiniProgramData(encryptedData, sessionKey, iv string) (decryptedData []byte, err error) { return SNSDecodeMiniProgramData(encryptedData, sessionKey, iv)