admin管理员组文章数量:1315017
I am trying to upload a video to Tiktok using this endpoint:
/
Following the official docs:
(After successfully authenticating with Tiktok and getting an access token using the Login Kit API). I am getting a response that suggests success (with error_code=0 and a non-empty share_id), however nothing gets uploaded and my Tiktok app's callback url does not seem to be getting triggered with any status update.
I've tried hitting the API from several different environments - a Node.js runtime (using Axios), a cURL request from 2 different machines (all getting the result described above) and also from my frontend code using Fetch (this one got me a CORS error). Code snippets below.
Will appreciate any help since I'm out of ideas as for what to try next. Also if there are any other docs or online resources besides the one I linked to that might be helpful, any links to such will be great.
Note: I made sure my test videos are satisfying the constraints mentioned in the docs.
My Node.js code:
const url = `=${openId}&access_token=${accessToken}`;
const data = new FormData();
data.append('video', fs.createReadStream(path.join(os.tmpdir(), 'test.mp4')));
await axios.post(url, data, {
headers: data.getHeaders()
});
cURL request:
curl --location --request POST '=<open_id>&access_token=<access_token>' --form 'video=@"/path/to/video.mp4"'
Response payload (for both cURL and Node.JS requests):
{"data":{"err_code":0,"error_code":0,"share_id":"video.7031619168818448385.CGdXCmaC"},"extra":{"error_detail":"","logid":"2021111721133201024513311411A971D3"}}
Frontend code (Fetch, getting a 307 response with the same Tiktok URL (/share/video/upload...) in the Location header - resulting in CORS error):
const formData = new FormData();
formData.append('video', selectedFile);
const requestOptions = {
method: 'POST',
body: formData,
redirect: 'follow'
};
const URL = `=${accessToken}&open_id=${openId}`;
fetch(URL, requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.log('error', error));
I am trying to upload a video to Tiktok using this endpoint:
https://open-api.tiktok./share/video/upload/
Following the official docs: https://developers.tiktok./doc/web-video-kit-with-web
(After successfully authenticating with Tiktok and getting an access token using the Login Kit API). I am getting a response that suggests success (with error_code=0 and a non-empty share_id), however nothing gets uploaded and my Tiktok app's callback url does not seem to be getting triggered with any status update.
I've tried hitting the API from several different environments - a Node.js runtime (using Axios), a cURL request from 2 different machines (all getting the result described above) and also from my frontend code using Fetch (this one got me a CORS error). Code snippets below.
Will appreciate any help since I'm out of ideas as for what to try next. Also if there are any other docs or online resources besides the one I linked to that might be helpful, any links to such will be great.
Note: I made sure my test videos are satisfying the constraints mentioned in the docs.
My Node.js code:
const url = `https://open-api.tiktok./share/video/upload?open_id=${openId}&access_token=${accessToken}`;
const data = new FormData();
data.append('video', fs.createReadStream(path.join(os.tmpdir(), 'test.mp4')));
await axios.post(url, data, {
headers: data.getHeaders()
});
cURL request:
curl --location --request POST 'https://open-api.tiktok./share/video/upload?open_id=<open_id>&access_token=<access_token>' --form 'video=@"/path/to/video.mp4"'
Response payload (for both cURL and Node.JS requests):
{"data":{"err_code":0,"error_code":0,"share_id":"video.7031619168818448385.CGdXCmaC"},"extra":{"error_detail":"","logid":"2021111721133201024513311411A971D3"}}
Frontend code (Fetch, getting a 307 response with the same Tiktok URL (/share/video/upload...) in the Location header - resulting in CORS error):
const formData = new FormData();
formData.append('video', selectedFile);
const requestOptions = {
method: 'POST',
body: formData,
redirect: 'follow'
};
const URL = `https://open-api.tiktok./share/video/upload?access_token=${accessToken}&open_id=${openId}`;
fetch(URL, requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.log('error', error));
Share
Improve this question
asked Nov 17, 2021 at 21:50
giladmakergiladmaker
611 silver badge3 bronze badges
5
- Did you find a solution to this issue? Is it relate to app approval or callback handle? – Chen Commented Nov 25, 2021 at 8:48
- Does this still work? I have tried the cURL link but it didn't worked. I get nothing back or any notification in app.. – Shino Lex Commented May 12, 2022 at 13:05
- Same issue here. Any solutions? – jaal kamza Commented May 25, 2022 at 1:28
- Has anyone figured out how to make this work ? – omenocal Commented Jun 3, 2022 at 17:44
- 1 Has anyone figured this out? I get a successful response, but the video does not show up in my inbox. – FriendlyMushroom Commented Oct 4, 2022 at 14:25
2 Answers
Reset to default 5You need to download the TikTok app then publish the video uploaded by your API.
The user who triggered the video upload should receive a notification on TikTok App after the video uploaded successfully and the user can publish the video on the app.
In case you get "Something went wrong, try again later". It is probably your region issue. You will need to try a vpn and try again.
本文标签: javascriptCan39t post videos to Tiktok using the Web Video Kit APIStack Overflow
版权声明:本文标题:javascript - Can't post videos to Tiktok using the Web Video Kit API - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741974085a2408016.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论