From 0c43086894644d49e0b6d545a123dfe6c306279a Mon Sep 17 00:00:00 2001 From: Allan Nava Date: Sun, 28 Jul 2024 14:21:14 +0200 Subject: [PATCH] added query params --- tiktok/content.go | 4 +++- tiktok/resty.go | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/tiktok/content.go b/tiktok/content.go index eed6363..f777a1b 100644 --- a/tiktok/content.go +++ b/tiktok/content.go @@ -205,7 +205,9 @@ func (o *tiktok) GetVideoList(count int64) (*VideoListResponse, error) { request := &VideoListRequest{ MaxCount: count, } - resp, err := o.restyPost(API_VIDEO_LIST, request) + resp, err := o.restyPostWithQueryParams(API_VIDEO_LIST, request, map[string]string{ + "fields": "cover_image_url,id,title", + }) if err != nil { return nil, err } diff --git a/tiktok/resty.go b/tiktok/resty.go index 13ac8b7..709ed72 100644 --- a/tiktok/resty.go +++ b/tiktok/resty.go @@ -38,6 +38,21 @@ func (o *tiktok) restyPost(url string, body interface{}) (*resty.Response, error return resp, nil } +func (o *tiktok) restyPostWithQueryParams(url string, body interface{}, queryParams map[string]string) (*resty.Response, error) { + resp, err := o.restClient.R(). + SetHeader("Accept", "application/json"). + SetHeader("Content-Type", "application/json"). + SetHeader("Auhtorization", "Bearer "+o.accessToken). + SetQueryParams(queryParams). + SetBody(body). + Post(url) + + if err != nil { + return nil, err + } + return resp, nil +} + func (o *tiktok) restyGet(url string, queryParams map[string]string) (*resty.Response, error) { resp, err := o.restClient.R(). SetHeader("Auhtorization", "Bearer "+o.accessToken).