Odyss3us
Odyss3us

Reputation: 6635

Facebook video upload via Graph API Javascript SDK

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!

Upvotes: 1

Views: 5319

Answers (2)

Guilherme Torres Castro
Guilherme Torres Castro

Reputation: 15350

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>

Upvotes: 1

Gajus
Gajus

Reputation: 73738

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

Upvotes: 0

Related Questions