2

In a previous version of the PHP SDK there was the ability in an App to get the Profile ID of the user that owned the page where the app was installed.

$facebook->get_profile_user()

This was possible without having the end user authorize access to the Facebook App.

However I can't find anything similar in the new JS or Graph API's. The closest thing I could find was the https://graph.facebook.com/<page_id>/admins, however it seems this call either doesn't work, or requires addition permissions:

Access Token:AAADF5PRI7BkBAKSz9Wqfbkuib6JH7WkZCQDZBgLNO10s1ZAMKF7BO7Y3YCVqkYNuCJ9QroWHYYn8n5wC8diPuBDPGsNUS5tDnZAZA6rFSx28VtpvVhUlY
Graph API: /210093142392039/admins
$this->facebook->api('/291231207559006/admins')

( ! ) Fatal error: Uncaught OAuthException: (#210) Subject must be a page. thrown in /html/classes/facebook/base_facebook.php on line 1033

Is this functionality gone? We were using the Profile ID as a key in a datasource, so it'd be ideal to keep this same key, if not we can start storing the page-id instead, however this would the users would have to reinitialize the app..

willemaw
  • 88
  • 1
  • 1
  • 4
  • It seems that no matter what I try, I'm getting the same response back as you are, even for my pages. It says on the docs that you can check if a certain user id is an admin here: http://developers.facebook.com/docs/reference/api/page/#admins but nothing more... confusing – Luke Oct 20 '11 at 20:17

2 Answers2

1

After September 22, 2011, manage_pages permission is required to do that. You must request for the manage_pages permission, get the page access_token and then make the admins request with the page access_token.

Please refer to http://developers.facebook.com/docs/reference/api/permissions/ for updated permissions.

Shih-Wen Su
  • 2,589
  • 24
  • 21
1

Well, I actually had the same problem some time back and found a solution for it. What i was doing was passing the user access token intead of the page access token. I would suggest that you should try something like

$pageIds=$facebook->api('/me/accounts');
$pageAccessToken=$pageIds["data"][1]["access_token"]; //get the access token for page "[1]" over here  

and then try

facebook->api('/<page id>/admins', 'get' , array("access_token" => $pageAccessToken));
Rahul Thakur
  • 824
  • 1
  • 12
  • 27
  • Doesn't the user still need to grant the app access for this to work since you're going after /me/accounts? I'm getting 'need active access token for user' exception.. – willemaw Oct 20 '11 at 21:15
  • Thats right you need a "manage_pages" permission for that. Well now that it is giving a "need active access token for user" exception i would suggest that you go through this article [http://stackoverflow.com/questions/2687770/do-facebook-oauth-2-0-access-tokens-expire](http://stackoverflow.com/questions/2687770/do-facebook-oauth-2-0-access-tokens-expire). Not sure but i hope it is of some help. – Rahul Thakur Oct 20 '11 at 21:35
  • Thanks for the info, I don't think this is a solvable problem anymore in this aspect. My solution is going to be to grab the PageID from the SignedRequest and use that as the key and if the AdminId is needed relate the two together at signup time, rather than some time later. – willemaw Oct 20 '11 at 22:19
  • I checked the graph api explorer, with the above code, and was able to get the admins or owners of the page. So its working for sure. There must be something wrong with the access token... well i am just guessing. Hey why dont you try it out on the graph api explorer itself and try to find out there if something's wrong. – Rahul Thakur Oct 21 '11 at 00:22