Facebook Cookbook - Jay Goldman [118]
Table 8-3. cookie table fields
Name
Type
Index
Description
uid
int
•
uid (user ID) associated with this cookie. This is the ID of the user who was using your application when the cookie was dropped.
name
string
Name of the cookie.
value
string
Value of the cookie.
expires
int
Expiry timestamp for the cookie. The cookie never expires if this is empty.
path
string
Path relative to your app’s callback URL with which the cookie is associated (i.e., if your app’s callback is http://www.someserver.com/myapp/ and the path is friends/add.php, then it was dropped by the page http://www.someserver.com/myapp/friends/add.php).
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
If you’d rather use the API to access cookies, try the Data.getCookies() and Data.setCookie() methods.
Retrieving All Cookies for a User
Problem
I need to retrieve all of the cookies dropped for a specific user using FQL.
Solution
The simplest query you could use is:
SELECT name, value FROM cookies WHERE uid = $uid;
Discussion
This query is automatically contextual to your app based on the API key you initialized the Facebook client with, so you’ll only be able to pull back cookies dropped by your app.
Retrieving a Specific Cookie
Problem
I need to retrieve a specific cookie using FQL.
Solution
SELECT name, value, path from cookies WHERE name="$name" AND uid = $user;
Discussion
Remember that all FQL queries are scoped to your application, so if you specify the name of a cookie from a different app, you’ll get back null.
Retrieving All Cookies for a Specific Path
Problem
I need to retrieve all of the cookies I’ve dropped for a specific page in my app using FQL.
Solution and Discussion
SELECT name, value, path from cookies WHERE path="$path" AND uid = $user;
Metrics Table
Problem
What’s the schema for the metrics table?
Solution
The metrics table holds all of the metrics recorded for your application. Its fields are listed in Table 8-4. You can view the same metrics from inside the Facebook Insights app (http://www.facebook.com/business/insights/app.php?id=12345). Metrics are calculated at midnight Pacific time everyday, so you should convert your date values into epoch seconds based on midnight PST (see Formatting Relative Time for more about epoch seconds). More information about this table, including an up-to-date listing of fields, can be found at http://wiki.developers.facebook.com/index.php/Metrics_(FQL).
Table 8-4. metrics table fields
Name
Type
Index
Description
end_time
int
•
The ending date for which these metrics were recorded, in epoch seconds. See Formatting Relative Time for an explanation of epoch seconds.
period
int
•
Length of time for which you want results, in seconds. Supported lengths are one day (86400 seconds), seven days (604800 seconds), and 30 days (2592000 seconds).
active_users
int
Number of active users in your app on this day.
unique_adds
int
Number of unique new users for your app on this day (if the same user added, removed, and then added it again, it only counts for one).
unique_removes
int
Number of unique removes for your app on this day (if the same user added, removed, added, and removed, it only counts for one).
unique_blocks
int
Number of unique blocks for your app on this day (if the same user blocked, unblocked, and blocked, it only counts for one).
unique_unblocks
int
Number of unique unblocks for your app on this day (if the same user blocked, unblocked, blocked, and unblocked, it only counts for one).
api_calls
int
Total number of API calls your app made on this