获取页面的选项卡,并通过图形添加标签页面到页面api方法fb.api()导致错误 [英] fetching page's tab and adding tab to the facebook pages by graph api method fb.api() result in error

查看:118
本文介绍了获取页面的选项卡,并通过图形添加标签页面到页面api方法fb.api()导致错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用户通过调用



FB.login(function(response){..)中的'manage_pages'权限登录我的应用程序....},{scope:'manage_pages'});



我想将我的应用标签添加到用户页面。我获取所有调用



FB.api('/ me / accounts?access_token = ACCESS_TOKEN','get',function(response){ ......} {{scope:'manage_pages'});



在获取所有页面后,我让用户选择一个页面他想要添加我的应用程序标签。



当用户选择一个页面时,我打电话给方法



FB.api('/ PAGE_ID / tabs?appId = myAppId& access_token = page_access_token_fetch_by_above_method','post',function(response){........}); p>

但方法返回错误作为响应,响应是:


/ ** / FB .ApiServer._callbacks.f17a44c23({error:{message:(#210)
主题必须是一个页面。,type:OAuthException}});


以下调用结果出现相同错误:



FB.api('/ PAGE_ID / tabs?access_token = page_access_token_fetch_by_above_method',function(response){}); strong>

解决方案

对我来说,它的工作原理如下:

  FB.api('/ me / accounts',function(response){
if(!response || response.error){
alert('Facebook get accounts error occurred'+ response.error);
} else {
var pageData = response.data;
/ *寻找正确的页面access_token * /
FB.Array.forEach(response.data,function(onePage){
if(onePage.id == page){
access_token = onePage.access_token;
}
});
/ *将应用程序添加到页面* /
FB.api(页面+'/ 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' );
}
}); / *页尾/标签* /
}
}); / *结束/我/帐户* /

我希望它有帮助。


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) 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.

这篇关于获取页面的选项卡,并通过图形添加标签页面到页面api方法fb.api()导致错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆