Retrieving a Page
Problem
I need to retrieve a specific Page using FQL.
Solution
If you know the page_id
of
the Page you want, this is easy:
SELECT name, type, pic_square FROM page WHERE page_id = $page_id;
If you don’t know the page_id
but do know the name
, you can still
find it, as long as you know a user who’s a fan:
SELECT page_id, pic_square, type FROM page WHERE name = $name AND page_id IN (SELECT page_id FROM page_fan WHERE uid = $user;
Discussion
This is a little harder than some of the comparable queries on
other tables because there’s no way to do this without a subquery,
which is dependent on having a uid
.
As noted earlier, the outcome is that this will work only when the
current loggedinuser
or one of his
friends is a fan of the Page you’re looking for.
You’ll get an empty set if the current loggedinuser
doesn’t have permission to see
the Pages of the user you’re querying on.
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.