2017-10-17 101 views
0

我想要的視頻上傳至Facebook與反應,本機fbsdk共享視頻與反應,本機fbsk

到目前爲止,我設法一個圖像發佈到Facebook上與此代碼!

 const sharePhotoContent = { 
      contentType: 'photo', 
      photos: [ 
       { 
        imageUrl: uri, 
        userGenerated: false, 
       } 
      ] 
     }; 
     this.setState({ sharePhotoContent: sharePhotoContent, }) 
    }) 

我試圖用很多方式發佈視頻,但我找不到正確的方法來做到這一點?

//這一個不工作!

this.refs.viewShot.capture().then(uri => { 
     const shareVideoContent = { 
      contentType: 'video', 
      localUrl: image, 
     }; 
     this.setState({ shareVideoContent: shareVideoContent, }) 
    }) 

是否有人已經這樣做了?

會很棒!

回答

0

如果您選擇this page,您可以找到視頻共享內容結構。

export type ShareVideoContent = { 
    // The type of content to be shared is photo. 
    contentType: 'video', 

    // Common parameters for share content; 
    commonParameters?: ShareContentCommonParameters, 

    // URL for the content being shared. 
    contentUrl?: string, 

    // Video to be shared. 
    video: ShareVideo, 

    // Description of the video. 
    contentDescription?: string, 

    // Title of the video. 
    contentTitle?: string, 

    // The photo that represents the video. 
    previewPhoto?: SharePhoto, 
}; 

export type ShareVideo = { 
    // The URL to the video. Must point to the location of the video on disk. 
    localUrl: string, 
}; 
+0

感謝@bennygenel您的快速反應! – rickkorsten

+0

你曾經使用它嗎? – rickkorsten

+0

不是直接。如果您有任何問題,我可以嘗試提供幫助。只需使用當前版本更新您的代碼,以便我可以更好地檢查它。 – bennygenel

0

@bennygenel我做到了!

onImageLoad =() => { 
    const shareVideoContent = { 
     contentType: 'video', 
     video: 
      { 
       localUrl: './VID_207171017_113247.mp4', 
      } 
    }; 
    this.setState({ shareVideoContent: shareVideoContent, }) 

} 

但我得到一個錯誤,多數民衆贊成說:

不確定是不是一個對象(評估 'this.state.shareVideoContent')

+0

請更新您的問題與編輯選項,而不是添加一個答案,因爲它違反SO規則。它可以被刪除 – bennygenel