Facebook Query Language
The Facebook Query Language (FQL) is a SQL-style language specifically designed to
allow developers to interact with Facebook information. Facebook allows you to interact
with nine separate “tables” to query information directly. You have access to the following:
I’ll get into the specifics of the information you have access to in these “tables” later in
the book, but suffice to say, Facebook exposes a lot of information to you for your
application. And, like most SQL implementations, some additional functions allow you to
take a few shortcuts when you request user information:
• now() returns the current time.
• strlen(string) returns the length of the string passed to the function.
• concat(string1, string2,…, stringN) concatenates N strings together.
• substr(string, start, length) returns a substring from a given string.
• strpos(haystack, needle) returns the position of the character needle in the string
• lower(string) casts the given string to lowercase.
• upper(string) casts the given string to uppercase.
To write FQL, you follow basic SQL syntax. For example, to extract my name and
picture from Facebook, you would write a simple query like so:
SELECT name, pic
WHERE uid = 7608007
The previous snippet, when executed by the Facebook platform, will return a structure
(in a format that you define in your call) with a URL to the image of the profile image for
user 7608007. Calls like these are useful in giving you granular control of the information
you get back from the API.
Blog search terms:
- -facebook query language examples--FQL functions returns the position of the character needle in the string haystack-
Tags: facebook fan page —