I am making user to log in my app with 'manage_pages' permission by the call to
FB.login(function(response) {...... },{scope:'manage_pages'});
I want to add my app tab to a user page.I fetch all the pages of the user with the call to
FB.api('/me/accounts?access_token=ACCESS_TOKEN','get', function(response){......},{scope:'manage_pages'});
Now after fetching the all pages I let the user to select a page which he wants to add my app tab to.
when user select开发者_如何学C a page I make a call to the method
FB.api('/PAGE_ID/tabs?appId=myAppId&access_token=page_access_token_fetch_by_above_method', 'post',function(response) {........});
but method return error as response, response is:
/**/ FB.ApiServer._callbacks.f17a44c23({"error":{"message":"(#210) Subject must be a page.","type":"OAuthException"}});
even tabs fetching on a page with the following call result in same error:
FB.api('/PAGE_ID/tabs?access_token=page_access_token_fetch_by_above_method', function(response) {});
For me it was working like this:
FB.api('/me/accounts', function(response) {
if (!response || response.error) {
alert('Facebook get accounts error occured ' + response.error);
} else {
var pageData = response.data;
/* looking for the right page specific access_token */
FB.Array.forEach(response.data, function(onePage) {
if( onePage.id == page ) {
access_token = onePage.access_token;
}
});
/* adding the app to the page */
FB.api(page + '/tabs', 'POST', { app_id: app, access_token: access_token }, function(response) {
if (!response || response.error) {
alert('Facebook add app error ' + response.error);
} else {
alert('App has been added');
}
}); /* end of page/tabs*/
}
}); /* end of /me/accounts */
I hope it helps.
精彩评论