
http://oss.snoyman.com/Facebook-0.0.0alpha1.tar.gz

A simplistic library for accessing Facebook's API http://api.facebook.com. It will pass messages from your program (either desktop or web based) to the Facebook REST server. Please read "INFORMATION" below for more details, especially if writing a desktop version.

use Facebook; use CGI;
my $api_key = 'thisisprovidedbyfacebook'; my $secret = 'soisthis';
my $cgi = CGI->new; my $f = Facebook->new($api_key, $secret);
my $session = $cgi->param('session'); # Set in a previous request my $auth_token = $cgi->param('auth_token'); # Same
if(!(defined $session) && !(defined $auth_token)) { print $cgi->redirect('http://api.facebook.com/login.php?api_key=' . $api_key); exit; } elsif(defined $auth_token) { $f->auth_token($auth_token); if($f->{SESSION}) { print $cgi->redirect('?session=' . $f->{SESSION}); } else { print $cgi->redirect('?'); # Start over, something didn't work } exit; }


Given an auth_token that has already undergone login, grab the secret, session, and uid via a facebook.auth.getSession call.
Code based on java's FacebookRestClient.generateSig

Due to Facebook's anti-phishing approach, you need to allow the user to log in through their web browser. When writing a web app, this is easily handled (see the synopsis above). For a desktop application, this is more tricky. You'll need to manually edit the $browser variable in Facebook.pm to be the web browser (ie, /usr/bin/firefox). If you have any ideas on how to do this better, let me know.
This library will store all the information it needs to send requests, such as session. Once again, please read the "SYNOPSIS".