Reputation: 1283
This has been a big mystery to me so I'm gonna ask here in a hope that someone can help me with it.
So, I'm trying to use the TikTok API to Auto Publish
videos onto TikTok's account.
I cannot find any information about this on their API docs.
So I did a research and found out that other companies like 'Later' or 'HootSuit' have this Auto Publishing feature for TikTok.
So I signed up on Later to test how they do it. I found out that there are these Scopes/Permissions being used:
user.info.basic,
user.insights,
video.list,
video.insights,
comment.list,
comment.list.manage,
video.publish
and I found those from the URL when I allowed the Later TikTok App to be added to my TikTok account:
https://www.tiktok.com/auth/authorize?client_id=7051484449883553794&client_key=7051484449883553794&redirect_uri=https%3A%2F%2Fapp.later.com%2Fusers%2Fauth%2Ftiktok_business%2Fcallback%3Fstate%3De0af91a683a02ec0636ee1b42e6e9caf60ccc8295252260b&response_type=code&scope=user.info.basic%2Cuser.insights%2Cvideo.list%2Cvideo.insights%2Ccomment.list%2Ccomment.list.manage%2Cvideo.publish&state=e0af91a683a02ec0636ee1b42e6e9caf60ccc8295252260b
My TikTok app (this is the API app), asks for these permissions:
user.info.basic,
video.upload,
Now, I know that is the fist and most probably the main issue here BUT I don't have any option to add those Scopes to my App!
The only scopes that TikTok API mentions and talks about are these:
user.info.basic
video.list
video.upload
which you can see here:
https://developers.tiktok.com/doc/tiktok-api-scopes/
My app now only uploads the video on the users account and the users get a push notification on their app asking them to login to their account and edit/pulish the video!
So there is no auto publishing.
Just to clarify, the user's account is a business account as well as this is a requirement for the TikTok auto publishing to work.
The question is, where and how I can add those scopes/permissions to my App?
are there any other steps that I need to take?
Upvotes: 5
Views: 9226
Reputation: 71
first of all you need to add scops in your developer account like video.publish
, user.info.basic
.
and submit for review I think they will approve your app scops changes in 24 hours. then you need to use direct publish API for direct publish your video
which is 'https://open.tiktokapis.com/v2/post/publish/video/init/'
but you need to follow tiktok guideline https://developers.tiktok.com/doc/content-posting-api-get-started/ for direct publish
first of all need to call creator/info API for getting account info then you can use direct publish apis
here there are two option for uploading video FILE_UPLOAD
and PULL_FROM_URL
. if you have your videos uploaded on third party video storage so you can directly use that Video URL to direct post using PULL_FROM_URL
method but in this case you need to verify your video domain or if you have direct video then you can use FILE_UPLOAD
method
there is some detail documentation and guideline for video upload you can find it here https://developers.tiktok.com/doc/content-posting-api-media-transfer-guide/ this full guideline for video upload using chunk and video upload using url
Upvotes: 1
Reputation: 260
In case you will pass approval, you can use this code as an example:
export const postStory = async (story) => {
try {
const content = fs.readFileSync(TOKEN_PATH);
const token = JSON.parse(content);
let options = {
method: "POST",
headers: {
Authorization: "Bearer " + token.data.access_token,
"Content-Type": "application/json; charset=UTF-8",
},
};
let response = await fetch("https://open.tiktokapis.com/v2/post/publish/creator_info/query/", options);
let data = await response.json();
console.log(data);
const body = {
post_info: {
title: "#manga " + story.description.substring(0, 50).replaceAll("<", "").replaceAll(">", ""),
privacy_level: "PUBLIC_TO_EVERYONE",
disable_duet: false,
disable_comment: false,
disable_stitch: false,
video_cover_timestamp_ms: 2000,
},
source_info: {
source: "PULL_FROM_URL",
video_url: API + story.video,
},
};
console.log(body);
options = {
method: "POST",
headers: {
Authorization: "Bearer " + token.data.access_token,
"Content-Type": "application/json; charset=UTF-8",
},
body: JSON.stringify(body),
};
response = await fetch("https://open.tiktokapis.com/v2/post/publish/video/init/", options);
data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
};
Upvotes: 1
Reputation: 791
Since you are using a Tiktok Business account, may you should rather use the Marketing APi (https://ads.tiktok.com/marketing_api/docs?id=1753986142651394)
This has video publish scopes too and is a lot different from the Tiktok API you get from Tiktok for developers.
Note: Tiktok for developers API is geared towards general use, while the Marketing API is for Businesses, hence more features.
Caution JFYI, If you have a business account, you cannot monetize the content. I am facing the same issue, but i cant move to business account(and Marketing API) for that reason.
Upvotes: 1