/usr/share/doc/libwww-facebook-api-perl/examples/web-app.pl is in libwww-facebook-api-perl 0.4.18-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | #!/usr/bin/perl
# Copyright (c) 2008 David Romano <unobe@cpan.org>
use strict;
use warnings;
use CGI;
use WWW::Facebook::API;
my $APP_NAME = 'ReplaceMe';
my $API_KEY = 'ReplaceMe';
my $SECRET = 'ReplaceMe';
my $DESKTOP = 0;
my $facebook = WWW::Facebook::API->new(
app_path => $APP_NAME,
parse => 1,
api_key => $API_KEY,
secret => $SECRET,
desktop => $DESKTOP,
);
my %action_map = (
tos => sub {
print q{
<fb:title>Terms of Service</fb:title>
<fb:header>Terms of Service</fb:header>
<div style="padding: 10px">
REPLACE WITH OWN TEXT
</div>
}
},
about => sub { print "The Great New $APP_NAME"; },
'' => sub {
my ( $facebook, $uid, @args ) = @_;
print qq{<p>Hello <fb:name uid="$uid" useyou="false" />!</p>};
},
);
start($facebook);
sub start {
my $facebook = shift;
my $fb_params = $facebook->canvas->validate_sig( CGI->new );
my $log_in = $facebook->require_login( undef,
next => "$ENV{'PATH_INFO'}?$ENV{'QUERY_STRING'}" );
print $facebook->query->header( -expires => 'now' );
if ($log_in) {
print $log_in;
return;
}
else { # store credentials
$facebook->session(
uid => $fb_params->{'user'},
key => $fb_params->{'session_key'},
expires => $fb_params->{'expires'},
);
if ( !$fb_params->{'added'} ) {
$action_map{'tos'}->($facebook);
return;
}
}
find_action_for($facebook);
return;
}
sub find_action_for {
my $facebook = shift;
my ( $action, $uid );
($action) = ( $facebook->query->path_info =~ m[^/(\w+)] );
if ( exists $ENV{'QUERY_STRING'} ) {
($uid) = $ENV{'QUERY_STRING'} =~ /\bid=([^&]+)/;
}
if ( my $s = $action_map{$action} ) {
my @args = split m[(?<!\\)/],
( $facebook->query->path_info =~ m[^/(?:\w+)/(.*)] )[0];
@args = () unless @args;
$uid ||= $facebook->session_uid;
$s->( $facebook, $uid, @args );
}
else {
print '<fb:error>'
."<fb:message>I don't know how to do $action</fb:message>"
.'</fb:error>';
}
return;
}
|