Python Facebook download video from external link

I am trying to upload a facebook video from an external url. But I got an error when I posted it. I tried with local videos and everything works fine.

My simple code:

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 always the same:

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

      

I looked through the docs and found the file_url parameter, but it's still the same problem.

The video format is .mp4 so it should work.

Any idea?

Apparently this error message is very confusing. This is the same message when you have an access_token not working. For example, I have this error message when I try to use the user access token, not if I use the page access token.

+3


source to share


1 answer


I've never used source

, I'm sure to read video data from their API. Instead, I use it file_url

in my payload when passing video urls to the Facebook Graph API.

Please refer to their API doc for clarity on this ...

It is also possible that the file extension is tmp.mp4

causing problems. I had problems with valid video urls with non-standard file extensions like this. Is it possible to change this in source so the url doesn't have tmp

?

A typical missing payload using the Requests module for 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 also highly recommend that you get a persistent page access token . This is the best way to mitigate the complexities of the Facebook oAuth process.

facebook: persistent page access token?

+2


source







All Articles