The Facebook Query Language allows you to write SQL-like queries to fetch data
from the Graph API. I’ve written a simple gem named fql to simplify this in
ruby.
First of all install the gem by adding gem 'fql' to your Gemfile.
Now you can simply use the FQL queries like so:
1
| |
And it will return the matching records as an array of hashes:
1
| |
Using an access token
To access some resources you’ll need to have a valid access token.
1 2 | |
Using a multi-query
If you want to use multi-queries then just pass in a Hash instead of a string.
1 2 3 4 | |
Note that the result will be a bit different from that of a single query. It
will still return an array of hashes, but this time the hashes will have a
name and fql_result_set key.
The name is the name of the subquery and fql_result_set will contains the
results for that particular query.
1 2 3 4 5 6 7 8 9 10 | |
For more information on how the use FQL you can check out the official developer documentation.