Facebook: get a list of pages that the user is an administrator

I am using api chart.

I have a registered user and you want to return a list of page identifiers of all pages to which the user is an administrator.

Is there any way to do this? The documents are pretty bad - and circular.

+68
facebook facebook-graph-api facebook-page
Jun 03 '10 at
source share
10 answers

Simple using Graph API. Steps:

You can test this procedure in the graph explorer → Just click the "Get access token" button> in the "Advanced permission" section , check "manage_pages" and send it. He will provide you information about JAON with admin page.

+127
Nov 10 '11 at 8:27
source share

I solved this 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; }} 
+13
Jun 04 2018-10-06T00:
source share

You can call FB.api(/me/accounts) if you do not want to use FQL.

'accounts' is the connection of the User object. See the documentation for this @ http://developers.facebook.com/docs/reference/api/user

Of course, there is always a catch with Facebook. Now this method will return not only the pages on which the user is an administrator, but also which applications they have installed. I am pretty sure this is NOT intended behavior. It seems that I recall this a few months ago and get only a list of pages. The documentation does not mention applications in this list.

This is not an easy task to solve - Facebook returns the name, category and identifier for each item in the list, and each application has the category “Application”. I just make sure that I only list items whose category is not an “Application”.

+11
Nov 18 '10 at 22:31
source share

go to this address

https://developers.facebook.com/tools/explorer/431294226918345/?method=GET&path=me%2Faccounts%3Ftype%3Dpage `

Just click get access token and go to advanced resolution

Check manage_pages

and click "Get access token"

Then in FQL write this

i / bills? Type = Page

Click Submit. and you will get all the lists of pages that are logged in as admin

+8
May 29 '13 at 4:55
source share

You request permission using the JavaScript SDK at login

 FB.login(function(){}, {perms:'manage_pages'}); 

and then, as soon as they log in, you can get the pages (and applications) as follows:

 FB.api('/me/accounts', function(response){ console.log(response); }) 
+7
Jul 17 '12 at 9:00
source share

Please note that your solution returns pages as well as applications . If you strictly want Pages, you can use FQL Multiquery with the sentence "Type is not equal" as follows:

 { "query1":"select page_id from page_admin where uid = me()", "query2":"select page_id, name, page_url, type from page where type!='APPLICATION' AND page_id in (select page_id from #query1)" } 
+5
05 Oct '11 at
source share

You can also use the permission "pages_show_list" if you only need a list of facebook pages to which the user is an administrator.

The "manage_pages" permission will ask the user for permission to manage their pages, which may be too intrusive depending on what you need.

+5
Feb 04 '17 at 15:42 on
source share

Resolution

 $facebook->getLoginUrl( array( "scope" => "manage_pages" ) ); 

act

 $accounts = $facebook->api('/me/accounts'); return $accounts; 
+4
Jan 16 '14 at 10:59
source share
 <head> <link rel="stylesheet" href="@Url.Content("~/Content/jquery.remodal.css")"> </head> <body> <script type="text/javascript" src="@Url.Content("~/Scripts/Home/jquery.remodal.js")"></script> <div class="remodal" id="page-selector-remodal" data-remodal-id="pageselector"> <p>Please select a facebook page Share </p> <div id="page-name-container"> <select id="page-name" class="form-control"> </select> </div> <a class="remodal-confirm" id="facebookPageSelectSubmit" href="#">OK</a> <a class="remodal-cancel" id="remodal-cancel" href="#">CANCEL</a> </div> <div data-remodal-id="modal-status"> <p id="modal-status-content"> The Account you have selected does not have Email. </p> <br> <a class="remodal-confirm" href="#">OK</a> </div> <script type="text/javascript> (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')); window.fbAsyncInit = function () { FB.init({ appId: 'YOUR APP ID', cookie: true, // enable cookies to allow the server to access // the session xfbml: true, // parse social plugins on this page version: 'v2.2' // use version 2.1 }); }; var pageSelector = $('[data-remodal-id=pageselector]').remodal(); var modalstatus = $('[data-remodal-id=modal-status]').remodal(); function statusChangeCallback(response) { if (response.status === 'connected') { // Logged into your app and Facebook. //testAPI(); } else if (response.status === 'not_authorized') { // The person is logged into Facebook, but not your app. $("#modal-status-content").empty().html(response.status); modalstatus.open(); } else { $("#modal-status-content").empty().html(response.status); modalstatus.open(); // The person is not logged into Facebook, so we're not sure if // they are logged into this app or not. document.getElementById('status').innerHTML = 'Please log ' + 'into Facebook.'; } } function FacebookHandler() { FB.login(function (result) { if (result != null && result.authResponse != null && result.authResponse != undefined) { facebookPageData = result; FB.api('/me/accounts', function (accountsResult) { if (accountsResult != null && accountsResult.data.length != 0) { //open the remodal here pageSelector.open(); facebookAccountsData = accountsResult; var data = accountsResult['data']; if (data != null) { for (var i = 0; i < data.length; i++) { $("#page-name").append('<option value="' + data[i].id + '">' + data[i].name + '</option>'); } } unblockUI('body'); $("#flip-container, #feature-container, #branding-container, #intro-arrow-container, #share-container, #copyright-text-container").hide(); $("body").css("padding-right", "0"); } else { $("#modal-status-content").empty().html("The Account you have selected does not have any facebook page,<br />Post to Wall."); modalstatus.open(); pageSelector.open(); unblockUI('body'); } }); } else { $("#modal-status-content").empty().html("Unable to retrieve your details from facebook, try again after sometime."); modalstatus.open(); unblockUI('body'); } }, { scope: 'manage_pages, publish_stream' }); } $("#facebookPageSelectSubmit").on("click", function () { var facebookpageId = $("#page-name option:selected").val(); if (facebookpageId != null) { FB.api('/' + facebookpageId, function (identity) { if (identity != null) { FB.api('/' + facebookpageId, { fields: 'access_token' }, function (resp) { if (resp.access_token != null) { //Get the "resp"(Data) here } else { } }); } else { } }); } else { } }); </script> //Finally call the "FacebookHandler()" function on click </body> 
+1
Apr 23 '15 at 10:01
source share

In the new GRAPH API v3 with Javascript, use the Tasks field instead of the Perm 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 for 'ADMINISTER' in an array, look for 'MANAGE'.

Full details here: https://developers.facebook.com/docs/pages/access-tokens

0
Feb 06 '19 at 10:22
source share



All Articles