1

is it possible to upload a video to Facebook via the Graph API, using the Javascript SDK?

something like this...

FB.api('/me/videos', 'post', {message: "Test", source: "@http://video.link.goes/here.flv", access_token: "token"}, function(response) {
   console.log(response)
}); 

now I know that this won't work, but is there a way to achieve something like this using the Graph API and Javascript SDK?

If not, would it be safe to use the old REST api to upload the video clip?.. since it is going to be deprecated soon.

Thanx in advance!

Odyss3us
  • 6,457
  • 18
  • 74
  • 112

2 Answers2

1

Yes, you can do this posting data to an iframe like here, or you can use jQuery File Upload . The problem is you can't get response from iframe, using plugin you can use a page handle. Example:

<form id="fileupload" action="https://graph-video.facebook.com/me/videos" method="POST" enctype="multipart/form-data">
    <input type="hidden" name="access_token" value="user_access_token">
    <input type="text" name="title">
    <input type="text" name="description">
    <input type="file" name="file"> <!-- name must be file -->
</form>


<script type="text/javascript">

    $('#fileupload').fileupload({
        dataType: 'json',
        forceIframeTransport: true, //force use iframe or will no work
        autoUpload : true,
        //facebook book response will be send as param
        //you can use this page to save video (Graph Api) object on database
        redirect : 'http://pathToYourServer/videos?video=%s' 
    });
</script>
Community
  • 1
  • 1
Guilherme Torres Castro
  • 15,135
  • 7
  • 59
  • 96
  • You say Facebook response will be sent as param. Can you elaborate on that? What's the difference between a param and a json? – picardo Nov 17 '13 at 00:14
  • Also, I think you misspelled the name of the access_token field in your example. – picardo Nov 17 '13 at 00:49
  • @picardo thanks for the correction. when video uploaded is completed facebook will redirect to the page you inform in the redirect parameter, and the video parameter will be the video_id. – Guilherme Torres Castro Nov 18 '13 at 12:49
0

The question is very similar to the one asked here: Facebook new javascript sdk- uploading photos with it!.

Community
  • 1
  • 1
Gajus
  • 69,002
  • 70
  • 275
  • 438