2015-10-15 79 views
3

我試圖從與NPM包Facebook的節點-SDK如何使用Facebook的圖形API

發佈與消息正式職位或圖像做工精細我的服務器的NodeJS發佈使用Facebook的圖形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, 

回答

1

我用一個圖表REST API從解析上傳視頻至Facebook:

Parse.Cloud.httpRequest({ 
     method: 'POST', 
     url: 'https://graph.facebook.com/v2.5/{page_id}/videos?access_token='+token+'&message='+message+'&file_url='+image, 
     success: function(httpResponse) { 
      console.log(httpResponse.data); 
      response.success("result"); 
     }, 
     error:function(httpResponse){ 
      //console.log("Not logging this"); 
      console.error(httpResponse.message); 
      response.error("Failed to login"); 
     } 
    }); 
2

根據https://developers.facebook.com/docs/graph-api/video-uploads#errors的錯誤代碼的含義

視頻上傳超時。您的視頻上傳超時可能會完成。這可能是因爲網絡連接速度緩慢或視頻太大。

另外,根據https://developers.facebook.com/docs/graph-api/reference/user/videos/#Creating您需要將您的視頻發佈到另一個圖形API端點:

影片必須被編碼爲multipart/form-data併發布到graph-video.facebook.com而不是常規的圖形API URL。

POST /v2.5/{page-id}/videos HTTP/1.1 
Host: graph-video.facebook.com 

source=%7Bvideo-data%7D 
+0

能否請您就如何,使用的NodeJS做榜樣? –