Struggling to understand the documentation found here and here. Implementing Facebook's Javascript SDK.
async postVideo(page: IFacebookPage, videoFile: File): Promise<CreateAdResult> {
return new Promise<CreateAdResult>(async (resolve, reject) => {
try {
const data = new FormData()
data.append('source', videoFile)
const result = await this.post(`/${page.id}/videos`, page, { source: data })
resolve(result)
} catch (error) { reject(error) }
})
}
private async post(url: string, page: IFacebookPage, params: any): Promise<CreateAdResult> {
return new Promise<CreateAdResult>(async (resolve, reject) => {
const accessToken = await this.fetchFaceBookPageAccessToken(page.id)
this.FB().api(url, "post", { ...params, access_token: accessToken }, (response: any) => {
if (response && !response.error) {
resolve(CreateAdResult.PublishToFacebookSuccess)
} else {
const msg = response && response.error ? `Failed to post content to Facebook page with error: ${response.error.message} ` : `Failed to post ad to Facebook page!`
reject(Error(msg)) // <----- Ends up here!!
}
})
})
}
All efforts lead to an error message like below
Error: Failed to post content to Facebook page with error: There was a problem uploading your video file. Please try again.