NAME

WWW::Facebook::API - Facebook API implementation

VERSION

This document describes WWW::Facebook::API version 0.0.6

SYNOPSIS

use WWW::Facebook::API;

my $client = WWW::Facebook::API->new(
    throw_errors => 1,
    desktop => 1,
    api_key => '5ac7d432',
    secret => '459ade099c',
);

my $token = $client->auth->create_token
    ->{auth_createToken_response}->[0]->{content};
$client->login->login( $token ); # prompts for login credentials from STDIN
$client->auth->get_session( auth_token => $token );
my @friends = @{$client->friends->get->{friends_get_response}->[0]->{uid}};
use Data::Dumper;
print Dumper $client->friends->are_friends(
    uids1 => [@friends[0,1,2,3]],
    uids2 => [@friends[4,5,6,7]],
);
print 'You have '
    . $client->notifications->get->{notifications_get_response}->[0]
        ->{pokes}->[0]->{unread}->[0]
    .' unread poke(s).';
my @quotes = map { @{$_->{quotes}} }
    @{$client->users->get_info( uids => \@friends, fields => ['quotes'] )
        ->{users_getInfo_response}->[0]->{user}};
print 'A lot of quotes: '.@quotes."\n";
print "Random one:\t".$quotes[int rand @quotes]."\n";

DESCRIPTION

A Perl implementation of the Facebook API, working off of the Java and PHP implementations initially proffered by the Facebook development team. The results are returned as a hash parsed by XML::Simple with ForceArray => 1 and KeepRoot => 1. So, as per the API description at http://developers.facebook.com/documentation.php, there's a result key, with an array which has the result items (be they hashes or whatever) inside. I thought this would give the most direct access to the actual data without filtering any important data (or ordering of data) out.

SUBROUTINES/METHODS

auth

auth namespace of the API (See WWW::Facebook::API::Auth). All method names from the Facebook API are lower_cased instead of CamelCase, e.g., auth.createToken is auth->create_token

login

Not defined in the API, but useful for testing with your own account. Asks for username and password (not stored) to authenticate token. Called as $client->login->login($token);

events

events namespace of the API (See WWW::Facebook::API::Events). All method names from the Facebook API are lower_cased instead of CamelCase, e.g., events.getInWindow is events->get_in_window

fql

fql namespace of the API (See WWW::Facebook::API::FQL).

friends

friends namespace of the API (See WWW::Facebook::API::Friends). All method names from the Facebook API are lower_cased instead of CamelCase, e.g., friends.areFriends(list1, list2) is friends->are_friends(list1, list2)

groups

groups namespace of the API (See WWW::Facebook::API::Groups). All method names from the Facebook API are lower_cased instead of CamelCase, e.g., groups.getMembers(gid) is groups->get_members(gid)

notifications

notifications namespace of the API (See WWW::Facebook::API::Notifications).

photos

photos namespace of the API (See WWW::Facebook::API::Photos). All method names from the Facebook API are lower_cased instead of CamelCase, e.g., photos.getOfUser is photos->get_of_user

update

update namespace of the API (See WWW::Facebook::API::Update). Call update.decodeIDs with update->decode_ids

users

users namespace of the API (See WWW::Facebook::API::Users). All method names from the Facebook API are lower_cased instead of CamelCase, e.g., users.getInfo is users->get_info

simple

Defaults to false. WWW::Facebook::API::Simple defaults to true. Compare this module's synopsis with WWW::Facebook::API::Simple to see an example of what difference it makes. If set to true, makes all methods return an easier-to-manage value by dereferencing the top nodes of the XML hierarchy. If there is no ambiguity about what the requested value is, it will return that (e.g, auth.createToken will return the token, friends.get will return an array ref of uids, etc. ). If there is ambiguity (e.g., auth.getSession), then it will only dereference to the point where it cannot do so without losing crucial information.

DIAGNOSTICS

The errors that are thrown would most likely be from WWW::Facebook::API::Base or from DEPENDENCIES, so look there first.

CONFIGURATION AND ENVIRONMENT

WWW::Facebook::API requires no configuration files or environment variables.

DEPENDENCIES

Moose WWW::Mechanize XML::Simple Digest::MD5 Time::HiRes URI::Escape Crypt::SSLeay

INCOMPATIBILITIES

None.

BUGS AND LIMITATIONS

No bugs have been reported.

Please report any bugs or feature requests to bug-www-facebook-api-rest-client@rt.cpan.org, or through the web interface at http://rt.cpan.org.

AUTHOR

David Romano <unobe@cpan.org>

LICENSE AND COPYRIGHT

Copyright (c) 2006, David Romano <unobe@cpan.org>. All rights reserved.

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

DISCLAIMER OF WARRANTY

BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENSE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.