WWW::Facebook::FQL - Simple interface to Facebook's FQL query language


  use WWW::Facebook::FQL;

  ## Connect and log in:
  my $fb = new WWW::Facebook::FQL key => $public_key, private => $private_key;
  $fb->login($email, $password);

  ## Get your own name and pic back:
  $fb->query("SELECT name, pic FROM user WHERE uid=$fb->{uid}");

  ## Get your friends' names and pics:
  $fb->query("SELECT name, pic FROM user WHERE uid IN "
           . "(SELECT uid2 FROM friend WHERE uid1 = $fb->{uid})");

  ## Get results in manageable form:
  use JSON::Syck; # or whatever...
  $fb->format = 'JSON';
  my $arrayref = JSON::Syck::Load $fb->query("...");


WWW::Facebook::FQL aims to make it easy to perform Facebook Query Language (FQL) queries from a Perl program, rather than to reflect the whole PHP Facebook API. For those comfortable with SQL, this may be a more comfortable interface. Results are currently returned in the raw JSON or XML format, but more palatable options may be available in the future.

$fb = new WWW::Facebook::FQL key => value, ...

Create a new Facebook FQL session for user $EMAIL with password $PASS. Keyword arguments include

email -- the email address of your Facebook account.
pass -- your password.
verbose -- A number controlling debugging information.
key -- The public part of your API key.

You need to sign up for this on Facebook by joining the "Developers" group and requesting an API key.

private -- The private part of your API key.
format -- Data return format, either 'XML' (the default) or 'JSON'.

WWW::Facebook::FQL reads default values from the file $HOME/.fqlrc if it exists. It should contain the innards of an argument list, and will be evaluated like @args = eval "($FILE_CONTENTS)". The constructor will not prompt for any parameters; it is the calling program's responsibility to get sensitive information from the user in an appropriate way.


Log the current user out.

$result = $fb->query($QUERY)

Perform FQL query $QUERY, returning the result in format $FORMAT (either XML or JSON, JSON by default). FQL is a lot like SQL, but with its own set of weird and privacy-related restrictions; for a description, see


$fb->uid (read-only)
$fb->email (read-only)
$fb->verbose (read-write)
$fb->format (read-write)

%FIELDS -- table_name -> [fields]

Map table names to available fields. This is particularly useful since FQL doesn't allow "SELECT *".

%IXFIELDS -- table_name -> [indexed_fields]

Map table names to "indexable" fields, i.e. those fields that can be part of a WHERE clause.


%FIELDS and %IXFIELDS can be exported with the ':all' tag.


The canonical (PHP) API Documentation (, especially the FQL document (

WWW::Facebook::API for bindings to the full API.


Since FQL is so much like SQL, it might be cool to make DBD::Facebook...


Sean O'Rourke, <>


Copyright (C) 2007 by Sean O'Rourke

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 227:

Unterminated C<...> sequence