Facebook::Graph::Query - Simple and fast searching and fetching of Facebook data.
version 1.0502
my $fb = Facebook::Graph->new; my $perl_page = $fb->find('16665510298') ->include_metadata ->request ->as_hashref; my $sarah_bownds = $fb->find('sarahbownds') ->select_fields(qw(id name)) ->request ->as_hashref; # this one would require an access token my $new_years_posts = $fb->query ->from('posts') ->where_since('1 January 2011') ->where_until('2 January 2011') ->limit(25) ->date_format('U') ->request ->as_hashref; # this one would require an access token my $new_car_posts = $fb->query ->search('car', 'my_news') ->where_since('yesterday') ->request ->as_hashref;
This module presents a programatic approach to building the queries necessary to search and retrieve Facebook data. It provides an almost SQL like way of writing queries using code. For example:
my $results = $fb ->select_fields(qw(id name)) ->search('Dave','user') ->where_since('yesterday') ->limit_results(25) ->request ->as_hashref;
The above query, if you were read it like text, says: "Give me the user ids and full names of all users named Dave that have been created since yesterday, and limit the result set to the first 25."
Fetch a single item.
The unique id or object name of an object.
Example: For user "Sarah Bownds" you could use either her profile id sarahbownds or her object id 767598108.
sarahbownds
767598108
If you prefer to search by keyword see the search method.
search
One of the following contexts:
The current user's news feed (home page). Requires that you have an access_token so you know who the current user is.
All public posts.
All people.
All pages.
All events.
All groups.
Perform a keyword search on a group of items.
If you prefer not to search by keyword see the from method.
from
They keywords to search by.
See the context param in the from method.
context
The result set will only return a certain number of records when this is set. Useful for paging result sets. Returns $self for method chaining.
$self
The result set dates will be formated in the defined formats. Specify the format by reference the PHP date format spec: http://php.net/manual/en/function.date.php. (eg. ->date_format('U')->) Useful for getting epoch for datatime. Returns $self for method chaining.
An integer representing the number of records to be returned.
Skips ahead the result set by the amount. Useful for paging result sets. Is only applied when used in combination with limit_results. Returns $self for method chaining.
limit_results
An integer representing the amount to offset the results by.
Adds metadata to the result set including things like connections to other objects and the object type being returned. Returns $self for method chaining.
Defaults to 1 when the method is called, but defaults to 0 if the method is never called. You may set it specifically by passing in a 1 or 0.
Limit the result set to only include the specific fields if they exist in the objects in the result set. Returns $self for method chaining. May be called multiple times to add more fields.
An array of fields you want in the result set.
Example: 'id', 'name', 'picture'
Limit the result set to these specifically identified objects. Returns $self for method chaining. May be called multiple times to add more ids.
An array of object ids, object names, or URIs.
Example: 'http://www.thegamecrafter.com/', 'sarahbownds', '16665510298'
Include only records that were created before date. Returns $self for method chaining.
date
Anything accepted by PHP's strtotime function http://php.net/manual/en/function.strtotime.php.
Include only records that have been created since date. Returns $self for method chaining.
Returns a URI string based upon all the methods you've called so far on the query. Mainly useful for debugging. Usually you want to call request and have it fetch the data for you.
request
Forms a URI string based on every method you've called so far, and fetches the data. Returns a Facebook::Graph::Response object.
Optionally pass in your own URI string and all the other options will be ignored. This is mainly useful with metadata connections. See include_metadata for details.
include_metadata
Facebook::Graph is Copyright 2010 - 2012 Plain Black Corporation (http://www.plainblack.com) and is licensed under the same terms as Perl itself.
2 POD Errors
The following errors were encountered while parsing the POD:
You forgot a '=back' before '=head2'
=back without =over
To install Facebook::Graph, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Facebook::Graph
CPAN shell
perl -MCPAN -e shell install Facebook::Graph
For more information on module installation, please visit the detailed CPAN module installation guide.