Home » Facebook » Facebook Query Language

Facebook Query Language

Tuesday, March 8th, 2011 | Facebook

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:
• user
• friend
• group
• group_member
• event
• event_member
• photo
• album
• phototag
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
haystack.
• 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
FROM user
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:

Tags:

Related Facebook Query Language

12 Signs You Really-really Pregnant

12 Signs You Really-really Pregnant .Okey, there are two lines in your test

Hello world!

Welcome to WordPress. This is your first post. Edit or delete it, then

Euro 2012 Top Scorer Van Persie or Gomez

Euro 2012 Top Scorer Van Persie  or Gomez The event brings Euro 2012

List Best Movie 2011 Release

List Best Movie 2011 Release A GLASS tank containing a pet chameleon (voiced