Net-Facebook-Oauth2
view release on metacpan or search on metacpan
examples/CGI/facebook.pl view on Meta::CPAN
my $fb = Net::Facebook::Oauth2->new(
application_id => 'your_application_id', ##get this from your facebook developers platform
application_secret => 'your_application_secret', ##get this from your facebook developers platform
callback => 'http://your-domain.com/callback', ##Callback URL, facebook will redirect users after authintication
);
##you can find more about facebook scopes/Extended Permissions at
##http://developers.facebook.com/docs/authentication/permissions
my $url = $fb->get_authorization_url(
scope => ['user_posts','manage_pages', 'user_friends'], ###pass scope/Extended Permissions params as an array telling facebook how you want to use this access
display => 'page' ## how to display authorization page, other options popup "to display as popup window" and wab "for mobile apps"
);
##now redirect to the authorization page
print $cgi->redirect($url);
}
sub callback {
##this sub represent the callback block, where facebook will send users back upon authorization
my $cgi = CGI->new;
examples/Catalyst/Facebook.pm view on Meta::CPAN
application_secret => 'your_application_secret', ##get this from your facebook developers platform
callback => 'http://localhost:3000/facebook', ##Callback URL, facebook will redirect users after authintication
);
#### first check if callback URL doesn't contain a verifier code "code" parameter
if (!$params->{code}){
##there is no verifier code passed so let's create authorization URL and redirect to it
my $url = $fb->get_authorization_url(
scope => ['user_posts','manage_pages', 'user_friends'], ###pass scope/Extended Permissions params as an array telling facebook how you want to use this access
display => 'page' ## how to display authorization page, other options popup "to display as popup window" and wab "for mobile apps"
);
##you can find more about facebook scopes/Extended Permissions at
##http://developers.facebook.com/docs/authentication/permissions
$c->res->redirect($url);
}
else {
####second step, we recieved "verifier" code parameters, now get access token
###you need to pass the verifier code to get access_token
my $access_token = $fb->get_access_token( code => $params->{code} );
lib/Net/Facebook/Oauth2.pm view on Meta::CPAN
if (defined $options{debug_token_url}) {
croak "cannot pass debug_token_url AND api_version" if defined $options{api_version};
$self->{debug_token_url} = $options{debug_token_url};
}
else {
$self->{debug_token_url} = "https://graph.facebook.com/$api_version/debug_token";
}
$self->{browser} = $options{browser} || LWP::UserAgent->new;
$self->{display} = $options{display} || 'page'; ## other values popup and wab
$self->{access_token} = $options{access_token};
return bless($self, $class);
}
sub get_authorization_url {
my ($self,%params) = @_;
$params{callback} ||= $self->{options}->{callback};
croak "You must pass a callback parameter with Oauth v2.0" unless defined $params{callback};
lib/Net/Facebook/Oauth2.pm view on Meta::CPAN
How to display Facebook Authorization page. Defaults to C<page>.
Can be any of the following:
=over 4
=item * C<page>
This will display facebook authorization page as full page
=item * C<popup>
This option is useful if you want to popup authorization page
as this option tell facebook to reduce the size of the authorization page
=item * C<wab>
From the name, for wab and mobile applications this option is the best, as
the facebook authorization page will fit there :)
=back
=item * C<response_type>
( run in 2.710 seconds using v1.01-cache-2.11-cpan-364913b4093 )