tiktok
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCall the TikTok Content Posting API with . The user's OAuth bearer
token is in ; every call needs . Base URL: .
curl + jq$TIKTOK_TOKENAuthorization: Bearer $TIKTOK_TOKENhttps://open.tiktokapis.com/v2Responses wrap everything in —
means success; otherwise show verbatim.
/ = re-connect TikTok.
{"data":...,"error":{"code","message","log_id"}}error.code == "ok"error.message401access_token_invalidbash
T="https://open.tiktokapis.com/v2"; AUTH="Authorization: Bearer $TIKTOK_TOKEN"使用调用TikTok Content Posting API。用户的OAuth bearer token存储在中;每次调用都需要携带请求头。基础URL:。
curl + jq$TIKTOK_TOKENAuthorization: Bearer $TIKTOK_TOKENhttps://open.tiktokapis.com/v2所有响应都包裹在结构中——当时表示请求成功;否则直接显示的内容。若返回/,则需要重新连接TikTok账号。
{"data":...,"error":{"code","message","log_id"}}error.code == "ok"error.message401access_token_invalidbash
T="https://open.tiktokapis.com/v2"; AUTH="Authorization: Bearer $TIKTOK_TOKEN"Profile (account card)
Profile (account card)
curl -sS -H "$AUTH" "$T/user/info/?fields=open_id,display_name,avatar_url"
| jq '.data.user'
| jq '.data.user'
undefinedcurl -sS -H "$AUTH" "$T/user/info/?fields=open_id,display_name,avatar_url"
| jq '.data.user'
| jq '.data.user'
undefinedUpload a video to the user's inbox / drafts (v1)
将视频上传至用户的收件箱/草稿箱(v1版本)
The simplest path is : TikTok fetches the video from a public URL
on a verified domain (AceData's is verified for this app).
PULL_FROM_URLcdn.acedata.cloudbash
VIDEO_URL="https://cdn.acedata.cloud/...mp4" # must be on a verified domain
curl -sS -X POST -H "$AUTH" -H "Content-Type: application/json" -d "$(jq -n --arg u "$VIDEO_URL" \
'{source_info:{source:"PULL_FROM_URL", video_url:$u}}')" \
"$T/post/publish/inbox/video/init/" | jq '{publish_id: .data.publish_id, error}'This drops the video into the user's TikTok inbox — they open the TikTok app
to add caption / sound / privacy and post. Poll status:
bash
curl -sS -X POST -H "$AUTH" -H "Content-Type: application/json" \
-d '{"publish_id":"PUBLISH_ID"}' "$T/post/publish/status/fetch/" \
| jq '.data | {status, fail_reason}'最简单的方式是使用:TikTok会从已验证域名上的公开URL拉取视频(AceData的已为本应用完成验证)。
PULL_FROM_URLcdn.acedata.cloudbash
VIDEO_URL="https://cdn.acedata.cloud/...mp4" # must be on a verified domain
curl -sS -X POST -H "$AUTH" -H "Content-Type: application/json" -d "$(jq -n --arg u "$VIDEO_URL" \
'{source_info:{source:"PULL_FROM_URL", video_url:$u}}')" \
"$T/post/publish/inbox/video/init/" | jq '{publish_id: .data.publish_id, error}'此操作会将视频存入用户的TikTok收件箱——用户需要打开TikTok应用,添加标题、音效、设置隐私权限后发布。轮询上传状态的命令:
bash
curl -sS -X POST -H "$AUTH" -H "Content-Type: application/json" \
-d '{"publish_id":"PUBLISH_ID"}' "$T/post/publish/status/fetch/" \
| jq '.data | {status, fail_reason}'Gotchas
注意事项
- v1 = inbox upload only. True "Direct Post" (set caption + privacy via API,
posts immediately) needs the scope and a passed Content Posting audit — not available until then. Don't call
video.publish/creator_info(Direct Post) here; they require that scope./post/publish/video/init/ - only works from a domain verified in the TikTok developer app. If the video isn't on a verified domain, use the chunked
PULL_FROM_URLflow instead (init → PUT byte ranges → status).FILE_UPLOAD - Unaudited apps are rate-limited and may restrict visibility to .
SELF_ONLY
- v1版本仅支持上传至收件箱。真正的“直接发布”(通过API设置标题和隐私权限并立即发布)需要权限,且需通过Content Posting审核——目前暂未开放。请勿在此处调用
video.publish或creator_info(直接发布接口),这些接口需要上述权限。/post/publish/video/init/ - 仅支持从TikTok开发者应用中已验证的域名拉取视频。若视频不在已验证域名上,请改用分块的
PULL_FROM_URL流程(初始化→PUT字节范围→查询状态)。FILE_UPLOAD - 未通过审核的应用会受到速率限制,且可能将可见性限制为。
SELF_ONLY