I'm trying to post a video using Facebook Graph API from my Nodejs server with the npm package Facebook-node-sdk
Posting regular posts with message or images work fine for me, but no videos
here is my code :
var FB = require('fb');
var request = require('request');
FB.setAccessToken('MY_APP_ACCESS_TOKEN');
var params = {};
params['source'] = "@video.3gp";
params['title'] = "test video";
params['video_file_chunk'] = "@video.3gp";
FB.api('me/videos', 'post', params , function (res) {
if(!res || res.error) {
console.log(!res ? 'error occurred' : res.error);
return;
}
console.log('Post Id: ' + res.id);
});
the video is in the same folder as my js running file.
I'm getting error code
type: 'FacebookApiException',
code: 390,
error_subcode: 1363030,
According to https://developers.facebook.com/docs/graph-api/video-uploads#errors the error code means
Video Upload Timeout. Your video upload timed out before it could be completed. This is probably because of a slow network connection or because the video is too large.
Also, according to https://developers.facebook.com/docs/graph-api/reference/user/videos/#Creating you need to publish your video to another Graph API endpoint:
Videos must be encoded as
multipart/form-data
and published tograph-video.facebook.com
instead of the regular Graph API URL.
POST /v2.5/{page-id}/videos HTTP/1.1
Host: graph-video.facebook.com
source=%7Bvideo-data%7D
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With