DaschPyth
DaschPyth

Reputation: 315

Python Facebook upload video from external link

I'm trying to upload a video to facebook from an external url. But I got error when I post it. I tried with local videos, and all works fine.

My simple code is :

answer = graph.post(
        path="597739293577402/videos",
        source='https://d3ldtt2c6t0t08.cloudfront.net/files/rhn4phpt3rh4u/2015/06/17/Z7EO2GVADLFBG6WVMKSD5IBOFI/main_OUTPUT.tmp.mp4',
    )

and my error is allways the same :

FacebookError: [6000] There was a problem uploading your video file. Please try again with another file.

I looked into the docs and found the parameter file_url but it still the same issue.

The format of the video is .mp4 so it should work.

Any idea ?

Apparently this error message is very confusing. It's the same message when you've an access_token who doesn't work. For example, I've this error message when I'm trying with my user access token and not if I use the Page access token.

Upvotes: 3

Views: 2852

Answers (1)

AdjunctProfessorFalcon
AdjunctProfessorFalcon

Reputation: 1840

I've never used source, I'm pretty sure that's for reading video data off their API. Instead, I use file_url in my payload when passing video file URLs to Facebook Graph API.

Refer to their API doc for clarity on that...

It's also possible that the tmp.mp4 file extension is causing you problems. I've had issues with valid video URLs with non-typical file extensions similar to that. Is it possible to alter that at the source so that the URL doesn't have the tmp ?

A typical payload pass using Requests module to their API that works for me might look something like this:

fburl = 'https://graph-video.facebook.com/v2.3/156588/videos?access_token='+str(access)
payload = {'name': '%s' %(videoName), 'description': '%s' %(videoDescription), 'file_url': '%s' %(videoUrl)}
flag = requests.post(fburl, data=payload).text
print flag
fb_res = json.loads(flag)

I would also highly recommend that you obtain a permanent page access token. It's the best way to mitigate the complexities of Facebook's oAuth process.

facebook: permanent Page Access Token?

Upvotes: 2

Related Questions