-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
76 lines (65 loc) · 2.33 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package main
import (
"context"
"fmt"
tiktokShop "github.com/huangchunlong818/go-tiktok-shop-api/tiktok"
"github.com/huangchunlong818/go-tiktok-shop-api/tiktok/common/config"
)
func main() {
ctx := context.Background()
tmp := config.WithApp(config.AppConfig{
AppId: "xxxx",
AppKey: "xxxx",
Secret: "xxxx",
})
//获取实例对象
shopClient := tiktokShop.NewTiktokShopClient(tmp)
// 授权相关
authClient := shopClient.GetAuthClient()
authUrl := authClient.GetAuthUrl("us")
fmt.Println("授权相关请求:", authUrl)
//授权API相关
authApiClient := shopClient.GetAuthApiClient()
r := authApiClient.GetAuthorizedShops(ctx, "ttttttttttt")
fmt.Println("授权API相关请求:", r)
//获取小部件相关API实例
widgetClient := shopClient.GetWidgetApiClient()
token := widgetClient.GetWidgetToken(ctx, "ttttttttttttt")
fmt.Println("小部件相关API请求:", token)
// 产品相关--品牌
productClient := shopClient.GetProductApiClient()
brands := productClient.GetBrands(ctx, "tttt", nil)
fmt.Println("产品相关API品牌请求:", brands)
// 产品相关--分类
cate := productClient.GetCate(ctx, "tttt", nil)
fmt.Println("产品相关API分类请求:", cate)
cateRule := productClient.GetCateRule(ctx, "tttt", "123", nil)
fmt.Println("产品相关API分类规则请求:", cateRule)
cateAttrsQuery := map[string]string{
"shop_cipher": "xxxxx",
"category_version ": "",
}
cateAttrs := productClient.GetCateAttrs(ctx, "tttt", "123", cateAttrsQuery)
fmt.Println("产品相关API分类属性请求:", cateAttrs)
// 产品相关--发布商品校验规则
prerequisitesQuery := map[string]string{
"shop_cipher": "xxxxx",
}
prerequisites := productClient.GetPrerequisites(ctx, "token", prerequisitesQuery)
fmt.Println("发布商品校验规则:", prerequisites)
// 产品相关--详情
productQuery := map[string]string{
"shop_cipher": "xxxxx",
"return_under_review_version": "0", // true: "1";false: "0"
}
product := productClient.GetProduct(ctx, "token", "productId", productQuery)
fmt.Println("产品详情:", product)
// 产品相关--产品列表
query := map[string]string{
"shop_cipher": "xxxx",
"page_size": "10",
}
body := map[string]any{}
products := productClient.GetProducts(ctx, "xxxxx", query, body)
fmt.Println("产品请求:", products)
}