tiktok

package
v0.2.34 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BASE_URL                  = "https://open.tiktokapis.com"
	QUERY_CREATOR_INFO        = "/v2/post/publish/creator_info/query/"
	POST_PUBLISH_VIDEO_INIT   = "/v2/post/publish/video/init/"
	PUBLISH_STATUS_FETCH      = "/v2/post/publish/status/fetch/"
	POST_PUBLISH_CONTENT_INIT = "/v2/post/publish/content/init/"
	USER_INFO                 = "/v2/user/info/"
	VIDEO_LIST                = "/v2/video/list/"
	RESEARCH_VIDEO_QUERY      = "/v2/research/video/query/"
	RESEARCH_AD_QUERY         = "/v2/research/adlib/ad/query/"
)

Variables

View Source
var (
	API_QUERY_CREATOR_INFO        = fmt.Sprintf("%s%s", BASE_URL, QUERY_CREATOR_INFO)
	API_POST_PUBLISH_VIDEO_INIT   = fmt.Sprintf("%s%s", BASE_URL, POST_PUBLISH_VIDEO_INIT)
	API_PUBLISH_STATUS_FETCH      = fmt.Sprintf("%s%s", BASE_URL, PUBLISH_STATUS_FETCH)
	API_POST_PUBLISH_CONTENT_INIT = fmt.Sprintf("%s%s", BASE_URL, POST_PUBLISH_CONTENT_INIT)
	API_USER_INFO                 = fmt.Sprintf("%s%s", BASE_URL, USER_INFO)
	API_VIDEO_LIST                = fmt.Sprintf("%s%s", BASE_URL, VIDEO_LIST)
	API_RESEARCH_VIDEO_QUERY      = fmt.Sprintf("%s%s", BASE_URL, RESEARCH_VIDEO_QUERY)
	API_RESEARCH_AD_QUERY         = fmt.Sprintf("%s%s", BASE_URL, RESEARCH_AD_QUERY)
)
View Source
var (
	PrivacyLevelWrong = errors.New("Privacy Level is not correct!")
	PhotoModeWrong    = errors.New("Photo mode is not correct!")
)
View Source
var Endpoint = oauth2.Endpoint{
	AuthURL:  "https://www.tiktok.com/v2/auth/authorize/",
	TokenURL: "https://open.tiktokapis.com/v2/oauth/token/",
}

Endpoint is TikTok's OAuth 2.0 endpoint.

Functions

func CheckPostMode added in v0.2.2

func CheckPostMode(mode string) bool

CheckPostMode checks if the given string matches any PostModeOptions

func CheckPrivacyLevel added in v0.2.0

func CheckPrivacyLevel(level string) bool

CheckPrivacyLevel checks if the given string matches any PrivacyLevelOptions

Types

type AccessTokenManagement added in v0.2.4

type AccessTokenManagement struct {
	AccessToken string `json:"access_token"`
	TokenType   string `json:"token_type"`
	ExpiresIn   int64  `json:"expires_in"`
}

type AdPublishedDateRange added in v0.2.5

type AdPublishedDateRange struct {
	Min string `json:"min"`
	Max string `json:"max"`
}

type DataPublishVideo added in v0.2.0

type DataPublishVideo struct {
	PubblishId string `json:"publish_id"`
}

type DataQueryCreatorInfo added in v0.2.0

type DataQueryCreatorInfo struct {
	CreatorAvatarUrl    string   `json:"creator_avatar_url"`
	CreatorUsername     string   `json:"creator_username"`
	CreatorNickname     string   `json:"creator_nickname"`
	PrivacyLevelOptions []string `json:"privacy_level_options"`
	CommentDisabled     bool     `json:"comment_disabled"`
	DuetDisabled        bool     `json:"duet_disabled"`
	StitchDisabled      bool     `json:"stitch_disabled"`
}

type DataUserInfo added in v0.2.2

type DataUserInfo struct {
	User UserInfo `json:"user"`
}

type DataVideoList added in v0.2.3

type DataVideoList struct {
	Videos []Video `json:"videos"`
}

type ErrorObject added in v0.2.0

type ErrorObject struct {
	Code    string `json:"code"`
	Message string `json:"message"`
	LogId   string `json:"log_id"`
}

type ITiktok

type ITiktok interface {
	//
	HealthCheck() error
	IsDebug() bool
	CodeAuthUrl() string
	SetAccessToken(token string)
	GetAccessToken() string
	//
	GetClientAccessTokenManagement() (*AccessTokenManagement, error)
	CreatorInfo() (*QueryCreatorInfoResponse, error)
	PostVideoInit(title, description, videoUrl string, privacyLevel string, disableDuet, disableComment, disableStitch bool) (*PublishVideoResponse, error)
	PublishVideo(publishId string) (*PublishStatusFetchResponse, error)
	GetVideoList(count int64) (*VideoListResponse, error)
	PostPhotoInit(title, description, privacyLevel string, photoUrls []string, photoMode string) (*PublishStatusFetchResponse, error)
	UserInfo() (*UserInfoResponse, error)
}

func NewTikTok

func NewTikTok(clientKey, clientSecret string, isDebug bool) (ITiktok, error)

type PhotoSourceInfo added in v0.2.2

type PhotoSourceInfo struct {
	Source          string   `json:"source"`
	PhotoCoverIndex int      `json:"photo_cover_index"`
	PhotoImages     []string `json:"photo_images"`
}

type PostInfo added in v0.2.0

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

type PostModeOptions added in v0.2.2

type PostModeOptions string
const (
	DIRECT_POST  PostModeOptions = "DIRECT_POST"
	MEDIA_UPLOAD PostModeOptions = "MEDIA_UPLOAD"
)

type PostPhotoInfo added in v0.2.2

type PostPhotoInfo struct {
	Title          string `json:"title"`
	Description    string `json:"description"`
	PrivacyLevel   string `json:"privacy_level"`
	DisableComment bool   `json:"disable_comment"`
	AutoAddMusic   bool   `json:"auto_add_music"`
}

type PrivacyLevelOptions added in v0.2.0

type PrivacyLevelOptions string
const (
	PUBLIC_TO_EVERYONE    PrivacyLevelOptions = "PUBLIC_TO_EVERYONE"
	MUTUAL_FOLLOW_FRIENDS PrivacyLevelOptions = "MUTUAL_FOLLOW_FRIENDS"
	FOLLOWER_OF_CREATOR   PrivacyLevelOptions = "FOLLOWER_OF_CREATOR"
	SELF_ONLY             PrivacyLevelOptions = "SELF_ONLY"
)

type PublishPhotoRequest added in v0.2.2

type PublishPhotoRequest struct {
	PostInfo   PostPhotoInfo   `json:"post_info"`
	SourceInfo PhotoSourceInfo `json:"source_info"`
	PostMode   string          `json:"post_mode"`  //  DIRECT_POST | MEDIA_UPLAOD
	MediaType  string          `json:"media_type"` // PHOTO
}

type PublishStatusFetch added in v0.2.0

type PublishStatusFetch struct {
	Status                   string  `json:"status"`
	FailReason               string  `json:"fail_reason"`
	UploadedBytes            int64   `json:"uploaded_bytes"`
	PublicalyAvailablePostId []int64 `json:"publicaly_available_post_id"`
}

type PublishStatusFetchRequest added in v0.2.0

type PublishStatusFetchRequest struct {
	PublishId string `json:"publish_id"`
}

type PublishStatusFetchResponse added in v0.2.0

type PublishStatusFetchResponse struct {
	Data  PublishStatusFetch `json:"data"`
	Error ErrorObject        `json:"error"`
}

type PublishVideoRequest added in v0.2.0

type PublishVideoRequest struct {
	PostInfo   PostInfo   `json:"post_info"`
	SourceInfo SourceInfo `json:"source_info"`
}

type PublishVideoResponse added in v0.2.0

type PublishVideoResponse struct {
	Data  DataPublishVideo `json:"data"`
	Error ErrorObject      `json:"error"`
}

type QueryCreatorInfoResponse added in v0.2.0

type QueryCreatorInfoResponse struct {
	Data  DataQueryCreatorInfo `json:"data"`
	Error ErrorObject          `json:"error"`
}

type ResearchAdQueryFilter added in v0.2.5

type ResearchAdQueryFilter struct {
	AdvertiserBusinessIDs []int64              `json:"advertiser_business_ids"`
	AdPublishedDateRange  AdPublishedDateRange `json:"ad_published_date_range"`
	CountryCode           string               `json:"country_code"`
}

type ResearchAdQueryRequest added in v0.2.5

type ResearchAdQueryRequest struct {
	Filters    ResearchAdQueryFilter `json:"filters"`
	SearchTerm string                `json:"search_term"`
}

type SourceInfo added in v0.2.0

type SourceInfo struct {
	Source   string `json:"source"`
	VideoUrl string `json:"video_url"`
}

type UserInfo added in v0.2.2

type UserInfo struct {
	OpenID    string `json:"open_id"`
	UnionID   string `json:"union_id"`
	AvatarUrl string `json:"avatar_url"`
}

type UserInfoResponse added in v0.2.2

type UserInfoResponse struct {
	Data  DataUserInfo `json:"data"`
	Error ErrorObject  `json:"error"`
}

type Video added in v0.2.3

type Video struct {
	ID            string `json:"id"`
	Title         string `json:"title"`
	CoverImageUrl string `json:"cover_image_url"`
}

type VideoListRequest added in v0.2.3

type VideoListRequest struct {
	MaxCount int64 `json:"max_count"`
}

type VideoListResponse added in v0.2.3

type VideoListResponse struct {
	Data  DataVideoList `json:"data"`
	Error ErrorObject   `json:"error"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL