无法使用 Web Video Kit API 将视频发布到 Tiktok [英] Can't post videos to Tiktok using the Web Video Kit API

查看:26
本文介绍了无法使用 Web Video Kit API 将视频发布到 Tiktok的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用此端点将视频上传到 Tiktok:

I am trying to upload a video to Tiktok using this endpoint:

https://open-api.tiktok.com/share/video/上传/

按照官方文档:https://developers.tiktok.com/doc/web-video-kit-with-web

(在成功通过 Tiktok 进行身份验证并使用登录工具包 API 获取访问令牌后).我收到了表明成功的响应(error_code=0 和非空的 share_id),但是没有上传任何内容,而且我的 Tiktok 应用的回调 url 似乎没有被任何状态更新触发.

(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.

我尝试从几个不同的环境访问 API - Node.js 运行时(使用 Axios),来自 2 台不同机器的 cURL 请求(都得到上述结果)以及使用 Fetch 的前端代码(这个一个给我一个 CORS 错误).下面的代码片段.

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.

我的 Node.js 代码:

My Node.js code:

    const url = `https://open-api.tiktok.com/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 --location --request POST 'https://open-api.tiktok.com/share/video/upload?open_id=<open_id>&access_token=<access_token>' --form 'video=@"/path/to/video.mp4"'

响应负载(对于 cURL 和 Node.JS 请求):

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"}}

前端代码(Fetch,在 Location 标头中获得具有相同 Tiktok URL (/share/video/upload...) 的 307 响应 - 导致 CORS 错误):

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.com/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));

推荐答案

你需要下载tiktok应用,然后发布你的api上传的视频.

You need to download tiktok app, than publish video uploaded by your api.

触发视频上传的用户应该会收到通知视频上传成功后,用户可以在抖音APP上在应用上发布视频.

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.

这篇关于无法使用 Web Video Kit API 将视频发布到 Tiktok的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆