Skip to content

Commit

Permalink
added new methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Allan-Nava authored Jul 25, 2024
1 parent 68a275d commit 074e5c6
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 2 deletions.
3 changes: 2 additions & 1 deletion tiktok/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ package tiktok

const (
BASE_URL = "https://open.tiktokapis.com"
)
QUERY_CREATOR_INFO = "v2/post/publish/creator_info/query"
)
3 changes: 2 additions & 1 deletion tiktok/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ curl --location --request POST 'https://open.tiktokapis.com/v2/post/publish/crea
--header 'Authorization: Bearer act.example12345Example12345Example' \
--header 'Content-Type: application/json; charset=UTF-8'
*/
func (o *tiktok) CreatorInfo() {
func (o *tiktok) CreatorInfo() (*QueryCreatorInfoResponse, error) {

return nil, nil
}

/*
Expand Down
36 changes: 36 additions & 0 deletions tiktok/request_content.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package tiktok

/*
{
"post_info": {
"title": "this will be a funny #cat video on your @tiktok #fyp",
"privacy_level": "MUTUAL_FOLLOW_FRIENDS",
"disable_duet": false,
"disable_comment": true,
"disable_stitch": false,
"video_cover_timestamp_ms": 1000
},
"source_info": {
"source": "PULL_FROM_URL",
"video_url": "https://example.verified.domain.com/example_video.mp4",
}
}
*/
type PublishVideoRequest struct {
PostInfo PostInfo `json:"post_info"`
SourceInfo SourceInfo `json:"source_info"`
}

type PostInfo struct {
Title string `json:"title"`
PrivacyLevel string `json:"privacy_level"`
DisableDuet bool `json:"disable_duet"`
DisableComment bool `json:"disable_comment"`
DisableStitch bool `json:"disable_stitch"`
VideoCoverTimestampMS int `json:"video_cover_timestamp_ms"`
}

type SourceInfo struct {
Source string `json:"source"`
VideoUrl string `json:"video_url"`
}
2 changes: 2 additions & 0 deletions tiktok/resty.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func (o *tiktok) restyPost(url string, body interface{}) (*resty.Response, error
resp, err := o.restClient.R().
SetHeader("Accept", "application/json").
SetHeader("Content-Type", "application/json").
SetHeader("Auhtorization" "Bearer "+ o.accessToken ).

Check failure on line 30 in tiktok/resty.go

View workflow job for this annotation

GitHub Actions / build (1.19.x)

syntax error: unexpected literal "Bearer " in argument list; possibly missing comma or )

Check failure on line 30 in tiktok/resty.go

View workflow job for this annotation

GitHub Actions / build (1.20.x)

syntax error: unexpected literal "Bearer " in argument list; possibly missing comma or )

Check failure on line 30 in tiktok/resty.go

View workflow job for this annotation

GitHub Actions / build (1.21.x)

syntax error: unexpected literal "Bearer " in argument list; possibly missing comma or )
SetBody(body).
Post(url)

Expand All @@ -38,6 +39,7 @@ func (o *tiktok) restyPost(url string, body interface{}) (*resty.Response, error

func (o *tiktok) restyGet(url string, queryParams map[string]string) (*resty.Response, error) {
resp, err := o.restClient.R().
SetHeader("Auhtorization" "Bearer "+ o.accessToken ).

Check failure on line 42 in tiktok/resty.go

View workflow job for this annotation

GitHub Actions / build (1.19.x)

syntax error: unexpected literal "Bearer " in argument list; possibly missing comma or )

Check failure on line 42 in tiktok/resty.go

View workflow job for this annotation

GitHub Actions / build (1.20.x)

syntax error: unexpected literal "Bearer " in argument list; possibly missing comma or )

Check failure on line 42 in tiktok/resty.go

View workflow job for this annotation

GitHub Actions / build (1.21.x)

syntax error: unexpected literal "Bearer " in argument list; possibly missing comma or )
SetQueryParams(queryParams).
Get(url)
//
Expand Down
11 changes: 11 additions & 0 deletions tiktok/tiktok.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ type ITiktok interface {
//
HealthCheck() error
IsDebug() bool
CreatorInfo() (*QueryCreatorInfoResponse, error)
//
}

Expand All @@ -14,6 +15,7 @@ type tiktok struct {
debug bool
clientKey string
clientSecret string
accessToken string
}

func NewTikTok(clientKey, clientSecret string, isDebug bool) (ITiktok, error) {
Expand All @@ -27,3 +29,12 @@ func NewTikTok(clientKey, clientSecret string, isDebug bool) (ITiktok, error) {
o.restClient.SetBaseURL(BASE_URL)
return o, nil
}


func (o *tiktok) SetAccessToken(token string){
o.accessToken = token
}

func (o *tiktok) GetAccessToken() string {
return o.accessToken
}

0 comments on commit 074e5c6

Please sign in to comment.