I\'m using the graph api.
I have a logged in user, and want to get back a list of page ids of all the pages that the user is an admin of.
Is there a way of d
With the new GRAPH API v3 with Javascript use the 'tasks' field instead of 'perms' field.
//Example JS Call
FB.api('/me/accounts?fields=name,picture.type(square),access_token,tasks', function(response) {console.log(response)});
//Example Response
{
"name": "Engage",
"picture": {
"data": {
"height": 50,
"is_silhouette": false,
"url": "https://scontent.xx.fbcdn.net/v/t1.0-1/c1.0.50.50a/p50x50/430597_259746387431503_2144341304_n.jpg?_nc_cat=103&_nc_eui2=AeGVrU8Wxe7k5BMvRXOEAcUo9dMIxyeMP9POPkYDwfgdRl8QquAtz1GcwXpJaK4z_0o&_nc_ht=scontent.xx&oh=e5b952a4adbbcd1b1af6b71b688f7284&oe=5CF9A64C",
"width": 50
}
},
"access_token": "XXXXXXXXXX",
"id": "253263371413138",
"tasks": [
"ANALYZE",
"ADVERTISE",
"MODERATE",
"CREATE_CONTENT",
"MANAGE"
]
}
Instead of looking of 'ADMINISTER' within the array, look for 'MANAGE'.
Full info here: https://developers.facebook.com/docs/pages/access-tokens
You ask for the permission with the JavaScript SDK on login
FB.login(function(){}, {perms:'manage_pages'});
and then once they log in you can retrieve the pages (and apps) as follow :
FB.api('/me/accounts', function(response){
console.log(response);
})
Its simple with Graph API. Steps:
manage_pages
permission from the user (extended permissions).You can test this procedure in the graph explorer -> Just click on 'Get Access Token' button-> under 'Extended permission' check 'manage_pages' & submit it. It will give you the admin-page-details JSON.
You can also use "pages_show_list" permission, if you want only the list of facebook pages the user is admin of.
The "manage_pages" permission will ask the user permission to manage his pages, which can be too intrusive depending on what you need it for.
Permission
$facebook->getLoginUrl( array( "scope" => "manage_pages" ) );
action
$accounts = $facebook->api('/me/accounts');
return $accounts;
go to this address
https://developers.facebook.com/tools/explorer/431294226918345/?method=GET&path=me%2Faccounts%3Ftype%3Dpage`
Just click on get Access token and go to extended Permission
Check the manage_pages checkbox
and click Get Access Token
Then under FQL write this
me/accounts?type=page
Click on Submit . and you will get all page lists that logged in user admin