Page Fan Table
Problem
What’s the schema for the page_fan
table?
Solution
The page_fan
table records
the relationships between page
s and
user
s. Its fields are listed in
Table 8-15. Queries to this table will
only return data the current user is allowed to see (i.e., you can’t
request fan
s for page
s that the current loggedinuser
can’t see). More information
about this table, including an up-to-date listing of fields, can be
found at http://wiki.developers.facebook.com/index.php/Page_fan_(FQL).
Table 8-15. page_fan table fields
Name | Type | Index | Description |
---|---|---|---|
| int | • | User ID of this user. |
| int | Page ID of the Page the user is a fan of. | |
| string | Type of this Page.
There are a way too many different Page types to enumerate
here. You can see them on the Create a Page page (http://www.facebook.com/pages/create.php).
They’re generally stored in the database in all caps, with
underscores in place of spaces (e.g., |
Note that only the field marked as “Index” in this table can be
used in an FQL query’s WHERE
clause, but any of the fields can appear in the SELECT
.
Discussion
There’s a really obvious index missing from this table, which
makes working with it a whole lot harder: page_id
(although the field exists, the lack
of an index on it means you can’t include it in FQL queries as part of
the WHERE
clause). As it currently stands, you can find the Pages a user is a fan of but not the users who are fans of a Page. It would fit better with the general FQL model to enable that index ...
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.