上传到Instagram业务帐户的视频始终返回&Quot;介质ID不可用&Quot;错误消息 [英] Video upload to Instagram Business Account always returns "Media ID is not available" error message

查看:31
本文介绍了上传到Instagram业务帐户的视频始终返回&Quot;介质ID不可用&Quot;错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将照片或视频发布到经过身份验证的Instagram业务帐户。

我已获得Instagram企业帐户的访问令牌,现在我希望将视频上载到该帐户,但不断收到此错误消息

媒体ID不可用

我按照说明上传了此处文档中的视频或照片https://developers.facebook.com/docs/instagram-api/guides/content-publishing/

请注意,下面的代码在上载照片时非常有效,但在上载视频时总是失败。

以下是我根据他们的文档编写的代码:

let mediaContainerUrl = `https://graph.facebook.com/${igUserId}/media`;
let containerParams = new URLSearchParams();
if (isPhoto) {
    containerParams.append('image_url', mediaUrl);
} else {
    containerParams.append('video_url', mediaUrl);
    containerParams.append('media_type', 'VIDEO');
}
containerParams.append('caption', caption);
containerParams.append('access_token', accessToken);
try {
    let mediaContainerResponse = await axios.post(mediaContainerUrl, containerParams);
    let { id } = mediaContainerResponse.data;

    // id above is supposed to be the creation_id needed for the next step below:

    // I can confirm that the id for the created media container was actually returned. 
    // So, it's weird for me to keep getting the Media ID not available error message.

    let mediaPublishResponse = await axios.post(`https://graph.facebook.com/${igUserId}/media_publish?creation_id=${id}&access_token=${access_token}`);
    let mediaPublishResponseData = mediaPublishResponse.data;
    let publishedMediaId = mediaPublishResponseData.id;
    console.log(`File uploaded to Instagram!`);

} catch (e) {
    console.log(`Instagram file upload failed miserably`);
    console.log(e);
}

请注意,上述mediaUrl来自远程URL,例如https://somewhere.com/video.mp4

再次说明,使用上述代码上传照片可以正常工作,但如果是视频,则无法正常工作。我不断收到以下完整错误消息:

OAuth&Quot;Facebook Platform&Quot;Invalid_Request&Quot;&Quot;媒体ID不可用

仔细观察后发现,视频确实生成了creation_id,所以老实说,我还是收到上面的错误信息,这很奇怪。

请告诉我,我会做错什么呢?

感谢任何解决此问题的建议。

推荐答案

因此,以下是问题所在。当您将视频上载到/media终结点时,视频的处理需要一些时间,并且在此期间视频将无法发布,因此/media_Publish终结点返回";Media ID Not Available";的原因。解决此问题的方法是检查容器的发布状态:GET: /{ig-container-id}?fields=status_code。仅当STATUS_CODE为&QOOT;COMPLETED";时,容器才可用于发布。有关更多详细信息,请查看下面的链接

IG content publish troubleshooting

这篇关于上传到Instagram业务帐户的视频始终返回&Quot;介质ID不可用&Quot;错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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