Reputation: 18346
I'm trying to publish a video file to my Facebook feed
My App is in Development mode
Here is how I init an SDK:
$(document).ready(function() {
initFacebook();
});
function initFacebook(){
window.fbAsyncInit = function() {
FB.init({
appId : '2xxxxxxxx7',
cookie : true,
xfbml : true,
version : 'v3.1'
});
FB.AppEvents.logPageView();
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "https://connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
}
Here is how I login:
var FB_ACCESS_TOKEN = null;
var FB_USER_ID = null;
FB.login(function(response) {
if (response.status === 'connected') {
FB_ACCESS_TOKEN = response.authResponse.accessToken;
FB_USER_ID = response.authResponse.userID;
}
}, {scope: 'publish_video'});
Then I have a file input and its event callback:
<input id="video-picker" type="file"/>
$("#video-picker").change(function (event) {
var file = this.files[0];
post(file);
});
And now I'm trying to post:
function post(file){
var formData = new FormData();
formData.append('title', "My awesome video title");
formData.append('description', 'My awesome video');
formData.append('source', file);
var url = 'https://graph-video.facebook.com/v3.1/' + FB_USER_ID + '/videos?access_token='+FB_ACCESS_TOKEN;
$.ajax({
type: "POST",
url: url,
data: formData,
contentType: false,
processData: false,
success: function(data){
console.log("SUCCESS", data);
},
error: function(data) {
console.log("ERROR", data);
}
});
}
But I'm getting the following error:
{
"error": {
"message": "(#100) No permission to publish the video",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "D16rmDQzzT6"
}
}
I do not understand what is wrong:
Here is the permissions my token has:
{
"data": [
{
"permission": "publish_video",
"status": "granted"
},
{
"permission": "public_profile",
"status": "granted"
}
]
}
Any ideas what's wrong?
Upvotes: 2
Views: 2283
Reputation: 18346
Will answer my own question:
I asked the same question at Facebook Developers group https://www.facebook.com/groups/fbdevelopers/permalink/1966752140034957/
And one guy gave me an explanation:
it's not what I wanted to do, but at least it's clear now
Upvotes: 3