Blog coding and discussion of coding about JavaScript, PHP, CGI, general web building etc.

Monday, August 8, 2016

Facebook Graph API + Facebook Pages

Facebook Graph API + Facebook Pages


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?

Answer by rmorrison for Facebook Graph API + Facebook Pages


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

Answer by gsharma for Facebook Graph API + Facebook Pages


@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!

Answer by dar for Facebook Graph API + Facebook Pages


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

Answer by PrateekSaluja for Facebook Graph API + Facebook Pages


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"        }     }  }  

Answer by Karthik for Facebook Graph API + Facebook Pages


Fql is the best way to get the pages of the user for which he is the admin. As the others like likes of user will give all the pages that the user like.

Answer by Brandon for Facebook Graph API + Facebook Pages


Here's what I use. It works perfect

$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'].'
'; }

This is of course after you have the session created for the fb user! The $uid would be the profile id# of the specific facebook user your returning of a list of managed pages for.

Answer by Karthik for Facebook Graph API + Facebook Pages


Use an fql query! That is the best way to get the pages for which the user is admin. You will also be able to restrict the names also. i.e pages with empty names A sample fql query which gives you the page details as well.

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 -- Id of the admin

NOTE This method will not work from version 2.1 of graph api as fql was deprecated from that version onwards

Answer by raukj for Facebook Graph API + Facebook Pages


access_token is valid for an hour or less. What should someone do in order to get the details even after. I was trying to result 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

This worked for an hour or so but how do i get the result after an hour...without going for a login.


Fatal error: Call to a member function getElementsByTagName() on a non-object in D:\XAMPP INSTALLASTION\xampp\htdocs\endunpratama9i\www-stackoverflow-info-proses.php on line 72

0 comments:

Post a Comment

Popular Posts

Powered by Blogger.