Get Pages
Problem
I need to find all of the Pages that the current user is a fan of.
Solution
Use the Pages.getInfo()
method:
$fields = array('name','pic_small','has_added_app'); $pages = $facebook->api_client->pages_getInfo(null,$fields,null,null);
Discussion
The four parameters are filters that allow you to constrain the
result set. The first is for pageid
s (Page IDs), which allows you to
retrieve info for a specific Page or a set of Pages:
$pages = array('25975037248', '5603889283'); $fields = array('name','pic_small','has_added_app'); $pages = $facebook->api_client->pages_getInfo($pages,$fields,null,null);
The second parameter is the set of fields you’d like returned in
your results, which can include any of the fields listed in Table 8-15. The third is for uid
s and allows you to return the Pages for
a different user (or set of users), provided that the current loggedinuser
is
allowed to see that info:
$users = array('567770429'); $fields = array('name','pic_small','has_added_app'); $pages = $facebook->api_client->pages_getInfo(null,$fields,$users,null);
The final parameter is for Page type and lets you filter the results down to a specified list. There doesn’t appear to be an easy way to get the list of possible types, but they are generally an all-uppercase version of the type’s name that you see when creating the page, with spaces replaced by underscores (e.g., “RETAIL”, “MUSICIAN”, “LOCAL_TECHNOLOGY_TELECOMMUNICATIONS_SERVICES”, etc.).
FQL equivalent
If you’d prefer to use FQL to access ...
Get Facebook Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.