Facebook Graph API + Facebook Pages

Using the Facebook API, given the username xyz (assuming it is authenticated on my site), how do I get a list of all the facebook pages the user manages?

+7
facebook facebook-graph-api
source share
9 answers

The accounts property in the user object says:

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

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

+15
source share

After receiving the access token, you can get all the information about the list of all facebook pages that the user administers.

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

The result 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" } } } 
+5
source share

Use fql query! This is the best way to get pages for which the user is an administrator. You can also restrict names. ie pages with empty names An example fql query that also gives you page information.

 SELECT page_id,page_url,name,pic_square FROM page WHERE page_id IN (SELECT page_id FROM page_admin WHERE uid = " + **UserId** + ") and name!='' 

UserId - Admin ID

Note This method will not work from version 2.1 of the graphical api, since fql is deprecated from this version.

+4
source share

I found the answer, you need to use FQL, going to the corresponding access_token:

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

+2
source share

Here is what I use. It works great

 $pages = $facebook->api(array('method' => 'fql.query','query' => 'SELECT page_id FROM page_admin WHERE uid = '.$uid.'')); foreach($pages as $k=>$v) { echo 'page id#:'.$v['page_id'].'<br/>'; } 

This, of course, after you created a session for user fb! $uid will be the profile identifier of # a particular facebook user, returning a list of managed pages.

+1
source share

@rmorrison is not a graphical API. With the new add-on "like", can you 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!

0
source share

Fql is the best way to get the pages of a user for whom he is an administrator. Since others, like users, will provide all the pages that the user will like.

0
source share

You can get a list of pages from a simple Facebook Graph API Hit.

 https://graph.facebook.com/{user-id}/accounts?access_token={access-token} 

It will provide a list of pages for the user that he created.

0
source share

access_token is valid for an hour or less. What does someone have to do to get the details even after. I tried to get the result from

https://graph.facebook.com/v2.3/search?q=coffee&type=place¢er=37.76,-122.427&distance=1000&access_token=xyz

It worked an hour or so, but how do I get the result in an hour ... without logging in.

-one
source share

All Articles