My users authenticated via an Instagram Business account and connected their pages within my app. The authentication was successful and when they wish to post a REEL to a connected page on Instagram the following code was used to achieve that:
async function publishVideoAsReel() {
let containerParams = new URLSearchParams();
let mediaContainerUrl = `https://graph.facebook.com/${igUserId}/media`;
containerParams.append('media_type', 'REELS'); //Notice here
containerParams.append('video_url', firstMediaUrl);
containerParams.append('thumb_offset', igVideoCoverOffset);
containerParams.append('access_token', pageAccessToken);
try {
let mediaContainerResponse = await axios.post(mediaContainerUrl, containerParams);
let { id: mediaContainerId } = mediaContainerResponse.data;
await finalizePost(igUserId, mediaContainerId, metaData);
} catch (e) {
console.log('Error posting to Instagram');
console.log(e);
}
}
async function finalizePost(igUserId, mediaContainerId, metaData) {
let mediaContainerStatusEndpoint = `https://graph.facebook.com/${mediaContainerId}?fields=status_code,status&access_token=${targetAccessToken}`;
try {
let { data: mediaContainerStatus } = await axios.get(mediaContainerStatusEndpoint);
let { status_code, status } = mediaContainerStatus;
if (status_code === 'ERROR') {
//Return here
}
if (status_code !== 'FINISHED') {
setTimeout(async () => {
//Wait For 5seconds and recursively check for the status of the uploaded video
await finalizePost(igUserId, mediaContainerId, metaData);
}, 5000);
} else {
//The video has been published, finalize the post here
try {
let mediaPublishResponse = await axios.post(`https://graph.facebook.com/${igUserId}/media_publish?creation_id=${mediaContainerId}&access_token=${targetAccessToken}`);
//More code omitted
} catch (e) {
}
}
} catch (e) {
}
}
With the above code the video was successfully published to the Page as a REEL and was also showing under the REELs tab.
However a user generated a report from Meta and noticed that the post was showing as Type:Post and not type:REEL.
So, I tried checking whether anything has changed as regards publishing REELs and then I bumped on this link https://developers.facebook.com/docs/video-api/guides/reels-publishing
Now, after attempting to follow the latest changes on that link I'm getting an error that says
"Subject does not have sufficient permission to post to target"
So, I have 3 questions:
- Was my initial code not doing the job of posting to Instagram as a true REEL
- Do I need to refactor to suite the changes in the new link https://developers.facebook.com/docs/video-api/guides/reels-publishing
- My initial code worked perfectly however when I tried following the instructions in the new docs in no 2 why am I getting that error above?
Thanks