Skip to content

Commit

Permalink
added query params
Browse files Browse the repository at this point in the history
  • Loading branch information
Allan-Nava authored Jul 28, 2024
1 parent 42c2477 commit 0c43086
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tiktok/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
15 changes: 15 additions & 0 deletions tiktok/resty.go
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down

0 comments on commit 0c43086

Please sign in to comment.