Skip to content

Commit

Permalink
s
Browse files Browse the repository at this point in the history
  • Loading branch information
allan committed Jul 29, 2024
1 parent 66d3351 commit 66c6f6c
Showing 1 changed file with 25 additions and 24 deletions.
49 changes: 25 additions & 24 deletions tiktok/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,16 @@ curl --location 'https://open.tiktokapis.com/v2/post/publish/video/init/' \
}'
*/
func (o *tiktok) PostVideoInit(title, videoUrl string, privacyLevel string) (*PublishVideoResponse, error) {
if !CheckPrivacyLevel(privacyLevel){
if !CheckPrivacyLevel(privacyLevel) {
return nil, PrivacyLevelWrong
}
request := &PublishVideoRequest{
PostInfo: PostInfo{
Title: title,
PrivacyLevel: privacyLevel,
DisableDuet: false,
Title: title,
PrivacyLevel: privacyLevel,
DisableDuet: false,
DisableComment: false,
DisableStitch: false,
DisableStitch: false,
},
SourceInfo: SourceInfo{
Source: "PULL_FROM_URL",
Expand Down Expand Up @@ -105,9 +105,9 @@ Host: open.tiktokapis.com
Authorization: Bearer {{AccessToken}}
Content-Type: application/json; charset=UTF-8
{
"publish_id": {PUBLISH_ID}
}
{
"publish_id": {PUBLISH_ID}
}
*/
func (o *tiktok) PublishVideo(publishId string) (*PublishStatusFetchResponse, error) {
request := &PublishStatusFetchRequest{
Expand All @@ -128,7 +128,6 @@ func (o *tiktok) PublishVideo(publishId string) (*PublishStatusFetchResponse, er
return &obj, nil
}


/* Photo
The /v2/post/publish/content/init/ endpoint allows you to post directly or upload photos to TikTok.
Expand All @@ -153,26 +152,26 @@ curl --location 'https://open.tiktokapis.com/v2/post/publish/content/init/' \
}'
*/

func (o *tiktok) PostPhotoInit(title, description, privacyLevel string, photoUrls []string, photoMode string) (*PublishStatusFetchResponse, error) {
if !CheckPrivacyLevel(privacyLevel){
func (o *tiktok) PostPhotoInit(title, description, privacyLevel string, photoUrls []string, photoMode string) (*PublishStatusFetchResponse, error) {
if !CheckPrivacyLevel(privacyLevel) {
return nil, PrivacyLevelWrong
}
if !CheckPostMode(photoMode){
if !CheckPostMode(photoMode) {
return nil, PhotoModeWrong
}
request := &PublishPhotoRequest{
PostInfo: PostPhotoInfo{
Title: title,
PrivacyLevel: privacyLevel,
Title: title,
PrivacyLevel: privacyLevel,
DisableComment: false,
AutoAddMusic: true,
AutoAddMusic: true,
},
SourceInfo: PhotoSourceInfo{
Source: "PULL_FROM_URL",
Source: "PULL_FROM_URL",
PhotoCoverIndex: 1,
PhotoImages: photoUrls,
PhotoImages: photoUrls,
},
PostMode: photoMode,
PostMode: photoMode,
MediaType: "PHOTO",
}
resp, err := o.restyPost(POST_PUBLISH_CONTENT_INIT, request)
Expand All @@ -190,23 +189,25 @@ func (o *tiktok) PostPhotoInit(title, description, privacyLevel string, photoUrl
return &obj, nil
}

/*
List Videos
/* List Videos
The /v2/video/list/ endpoint can return a paginated list for the given user's public TikTok video posts, sorted by create_time in descending order.
curl -L -X POST 'https://open.tiktokapis.com/v2/video/list/?fields=cover_image_url,id,title' \
-H 'Authorization: Bearer act.example12345Example12345Example' \
-H 'Content-Type: application/json' \
--data-raw '{
"max_count": 20
}'
--data-raw '{
"max_count": 20
}'
*/
func (o *tiktok) GetVideoList(count int64) (*VideoListResponse, error) {
request := &VideoListRequest{
MaxCount: count,
}
resp, err := o.restyPostWithQueryParams(API_VIDEO_LIST, request, map[string]string{
"fields": "cover_image_url,id,title",
"fields": "cover_image_url,id,title",
})
if err != nil {
return nil, err
Expand All @@ -220,4 +221,4 @@ func (o *tiktok) GetVideoList(count int64) (*VideoListResponse, error) {
}
o.debugPrint(obj)
return &obj, nil
}
}

0 comments on commit 66c6f6c

Please sign in to comment.