Mikael Andresen
Mikael Andresen

Reputation: 11

Facebook Graph API uploading videos

At work we have made a website where we can upload videos to facebook. We have encountered a problem; when a video is larger than 100MB, we get the following error: "An access token is required to request this ressource".

The access token is valid and we have no problems uploading videos below 100MB, so we are a bit puzzled why this happens.

I am using an Ajax post request with JavaScript/JQuery to upload the video.

    var formData = new FormData();
    formData.append("access_token", token);
    formData.append("id", "{page-id}");
    formData.append("title", $("#video_title").val());
    formData.append("description", $("#video_title").val());
    formData.append("source", $('#upload_btn').get(0).files[0]);
    var url = "https://graph.facebook.com/v2.4/{page-id}/videos";
    $.ajax({
        url: url,
        type: 'POST',
        data: formData,
        dataType: 'json',
        mimeType: "multipart/form-data",
        cache: false,
        contentType: false,
        processData: false,
        success: function (json) {
        },
        error: function(xhr, status, error) {
            alert(JSON.parse(xhr.responseText).error.message);
        }
    });

Any ideas why we are getting this error message or should we be uploading a different way?

Upvotes: 1

Views: 3252

Answers (1)

ifaour
ifaour

Reputation: 38115

The API domain used is incorrect, for video uploads you should point to this domain: https://graph-video.facebook.com/...

Upvotes: 2

Related Questions