通过图形 api 方法 fb.api() 获取页面的选项卡并将选项卡添加到 facebook 页面会导致错误 [英] fetching page's tab and adding tab to the facebook pages by graph api method fb.api() result in error
问题描述
我让用户通过调用以manage_pages"权限登录我的应用程序
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 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)主题必须是页面.","type":"OAuthException"}});
/**/ 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 */
希望对你有帮助.
这篇关于通过图形 api 方法 fb.api() 获取页面的选项卡并将选项卡添加到 facebook 页面会导致错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!