views:

349

answers:

4

Using Facebook's Graph API, given a username xyz (assuming they've authenticated my site), how do I get a list of all of the facebook pages that the user administers?

+2  A: 

I found the answer, you need to use FQL, passing in the appropriate access_token:

https://api.facebook.com/method/fql.query?query=SELECT%20page_id%20FROM%20page_admin%20WHERE%20uid=XXXX&access_token=YYYY

rmorrison
A: 

@rmorrison - This is not graph API though. With the new "like" addition, you can use this URL: h ttps://graph.facebook.com/me/likes?access_token=blah! or h ttps://graph.facebook.com/USER_ID/likes?access_token=blah!

gsharma
He's not looking for "likes", he's looking for pages the user administrates.
Daniel Schaffer
Do you know how to perform a like action on a page?
Tristan
+3  A: 

The accounts property on the user object says:

The Facebook pages owned by the current user. If the manage_pages permission has been granted, this connection also yields access_tokens that can be used to query the Graph API on behalf of the page.

http://developers.facebook.com/docs/reference/api/user

dar
Ooh this must be new... never noticed that connection before! Although, I'm not sure this is the right answer. You can be an admin on a page without being the "owner".
Daniel Schaffer
It looks like the right answer to me, it returns all pages I'm an admin on, even the ones I did not create myself.
dar
+4  A: 

Hello,

After getting access token you can get all details of list of all of the facebook pages that the user administers.

https://graph.facebook.com/[FACEBOOKUSERID]?metadata=1&access_token=

The output will look like

{
   "name": "Facebook Developer Garage Austin - SXSW Edition",
   "metadata": {
      "connections": {
         "feed": "http://graph.facebook.com/331218348435/feed",
         "picture": "https://graph.facebook.com/331218348435/picture",
         "invited": "https://graph.facebook.com/331218348435/invited",
         "attending": "https://graph.facebook.com/331218348435/attending",
         "maybe": "https://graph.facebook.com/331218348435/maybe",
         "noreply": "https://graph.facebook.com/331218348435/noreply",
         "declined": "https://graph.facebook.com/331218348435/declined"
      }
   }
}
PrateekSaluja