Reputation: 437
I am using the Facebook JS code for retrieving a list of pages of which I am assigned to as an admin. I get list of all such pages but one page is somehow not showing up. I have checked all the permissions and roles, using proper app id, also the app is showing active on that page but still somehow it is not showing up in the list and I need that page for getting page access token. Also I am using manage_pages
permissions in Facebook JS function.
So can someone please suggest a probable reason for the page not showing up in the list. The code I am using is below (which is completely facebook code except my app ID).
<script>
window.fbAsyncInit = function()
{
FB.init({
appId : 'xxxx6xx89xx5xxx', // app id is correct i have checked
xfbml : true,
version : 'v2.12'
});
};
(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 = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
function subscribeApp(page_id, page_access_token)
{
console.log('Subscribing page to app! ' + page_id);
FB.api(
'/' + page_id + '/subscribed_apps',
'post',
{access_token: page_access_token},
function(response)
{
console.log('Successfully subscribed page', response);
}
);
}
// Only works after `FB.init` is called
function myFacebookLogin()
{
FB.login(function(response)
{
console.log('Successfully logged in', response);
FB.api('/me/accounts', function(response)
{
console.log('Successfully retrieved pages', response);
var pages = response.data;
var ul = document.getElementById('list');
for (var i = 0, len = pages.length; i < len; i++)
for (var i=0; i < response.data.length; i++)
{
var page = pages[i];
var li = document.createElement('li');
var a = document.createElement('a');
a.href = "#";
a.onclick = subscribeApp.bind(this, page.id, page.access_token);
a.innerHTML = page.name;
li.appendChild(a);
ul.appendChild(li);
}
});
}, {scope: 'manage_pages'});
}
</script>
<button onclick="myFacebookLogin()">Login with Facebook</button>
<ul id="list"></ul>
Upvotes: 0
Views: 191
Reputation: 73984
Tell me if i missed something in the comments, but afaik it can only be those things:
You have more than 25 Pages, so you need to use the limit parameter or paging. Test it with the limit parameter: FB.api('/me/accounts', {limit: 100}, function(response) ...
You don´t have sufficient permissions for the Page
It´s a bug and you should report it to Facebook
Upvotes: 1