Facebook: get list of pages that a user is admin of
Solution 1
Its simple with Graph API. Steps:
- Get the
manage_pages
permission from the user (extended permissions). - Call the Graph API - https://graph.facebook.com/me/accounts
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.
Solution 2
I solved it with some FQL:
FB.api({method: 'fql.multiquery',
access_token: <access_token>,
queries: {
query1: 'select page_id from page_admin where uid = ' + <uid>,
query2: 'select page_id, name, page_url from page where page_id in (select page_id from #query1)'
}
}, function(queries){
var pages = queries[1].fql_result_set;
}}
Solution 3
go to this address
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
Solution 4
You can call FB.api(/me/accounts)
if you don't want to use FQL.
'accounts' is a connection of the User object. See the documentation for this @ http://developers.facebook.com/docs/reference/api/user
Of course, with Facebook, there's always a catch. Right now this method will return not only the pages the user is an admin of, but also what applications they have installed. I'm almost positive this is NOT the intended behavior - I seem to remember using this a few months ago and only getting a list of pages. The documentation makes no mention of applications in this list either.
This is an easy problem to solve though - Facebook returns the name, category, and id for each item on the list, and each application has a category of 'Application'. I'm simply making sure I only list items whose category is not 'Application'.
Solution 5
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);
})
Related videos on Youtube
EoghanM
Updated on November 03, 2020Comments
-
EoghanM over 3 years
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 doing this? The docs are pretty bad - and circular.
-
Darkwonder over 3 years10 years later, and the documentation is still bad.
-
Andy Wallace over 2 yearsbad is a SEVERE understatement. Gack.
-
-
EoghanM about 12 yearsSwitching answers as this sounds like the more standard/stable way of doing it. Although I would warn against any use of the word 'simple': everything is simple once you know how :)
-
Avisek Chakraborty about 12 yearsya. u r right. But there can be several solutions to a problem. We need to choose the simplest among them.
-
Jepser Bernardino about 12 yearsIf you're using FB PHP SDK it's easier: just $user_admin_pages = $facebok->api('/me/accounts');
-
ObscureRobot over 11 yearsAs of December 2012, the documentation for 'accounts' states that it will return pages and apps the user owns.
-
Yuval A. about 11 yearsThe advantage of querying with FQL vs. using a graph request is that graph always forces the returned data to be 'paged' (it only returns the first few results, and a link to the next few) - while in FQL it always returns the entire result-set in one time.
-
Kees C. Bakker over 10 yearsWhat is the difference between
{perms: 'manage_pages'}
and{scope: 'manage_pages'}
? -
Soorajlal K G over 9 yearsThanks. It lists pages only if the current user administrates app. Is there any way to list pages of another person?
-
Soorajlal K G over 9 yearsIs thr any way to list pages of another person
-
Serge S. almost 9 yearsWhere have you found that
me/accounts
supportstype
query parameter? -
Raptor almost 9 yearsYou seem to use some frameworks in your codes, would you mind to explain it?
-
Raptor almost 9 years@SoorajlalKG no, you won't have the permission to do so.
-
Kapitein Witbaard over 8 yearsAs of August 2014: "The FQL and REST APIs are no longer available in v2.1: Previously announced with v2.0, apps must migrate to versioned Graph API calls starting with v2.1.". In other words, the FQL can no longer be used.
-
Maha Dev over 8 yearsCan i get any facebook page details without login? i have my app id and app secret
-
activ8 over 7 years^ I need the same. Did you find anything about ?
-
Igorzovisk over 5 yearsJust posting a code is not a good answer, from my point of view.
-
Kris Stern about 4 yearsThink you can list the pages of another Facebook user if you supply their
id
in lieu ofme
in the endpoint for theGET
request... -
Masroor over 3 yearsI agree with @Soorajkal, this does not return the pages if the page is not in the app administered by the user. Which is what I need. Is there a way to do it?