我正在尝试通过 npm 包 Facebook-node-sdk 从我的 Nodejs 服务器使用 Facebook Graph API 发布视频
发布带有消息或图片的常规帖子对我来说很好,但没有视频
这是我的代码:
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);
});
视频和我的js运行文件在同一个文件夹下
我收到错误代码
type: 'FacebookApiException',
code: 390,
error_subcode: 1363030,
最佳答案
根据 https://developers.facebook.com/docs/graph-api/video-uploads#errors错误代码表示
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.
此外,根据 https://developers.facebook.com/docs/graph-api/reference/user/videos/#Creating您需要将视频发布到另一个 Graph API 端点:
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
关于node.js - 如何使用 Facebook Graph API 发布视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33160059/