Mahmoud A. Mehyar > Net-Facebook-Oauth2 > Net::Facebook::Oauth2

Download:
Net-Facebook-Oauth2-0.02.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.02   Source  

NAME ^

Net::Facebook::Oauth2 - a simple Perl wrapper around Facebook OAuth v2.0 protocol

SYNOPSIS ^

use CGI; my $cgi = CGI->new;

use Net::Facebook::Oauth2;

my $fb = Net::Facebook::Oauth2->new( application_id => 'your_application_id', application_secret => 'your_application_secret' );

###get authorization URL for your application my $url = $fb->get_authorization_url( scope => ['offline_access','publish_stream'], callback => 'http://yourdomain.com/facebook/callback', display => 'page' );

####now redirect to this url print $cgi->redirect($url);

##once user vauthorize your application facebook will send him/her back to your application ##to the callback link provided above

###in your callback block capture verifier code and get access_token

my $fb = Net::Facebook::Oauth2->new( application_id => 'your_application_id', application_secret => 'your_application_secret' );

my $access_token = $fb->get_access_token(code => $cgi->param('code')); ###save this token in database or session

##later on your application you can use this verifier code to comunicate ##with facebook on behalf of this user

my $fb = Net::Facebook::Oauth2->new( access_token => $access_token );

my $info = $fb->get( 'https://graph.facebook.com/me' ##Facebook API URL );

print $info->as_json;

DESCRIPTION ^

Net::Facebook::Oauth2 gives you a way to simply access FaceBook Oauth 2.0 protocol

For more information please see example folder shipped with this Module

SEE ALSO ^

For more information about Facebook Oauth 2.0 API

Please Check http://developers.facebook.com/docs/

get/post Facebook Graph API http://developers.facebook.com/docs/api

USAGE ^

Net::Facebook::Oauth->new( %args )

Pass args as hash. %args are:

$fb->get_authorization_url( %args )

Return an Authorization URL for your application, once you receive this URL redirect user there in order to authorize your application

$fb->get_access_token( %args )

Returns access_token string One arg to pass

$fb->get( $url,$args )

Send get request to facebook and returns response back from facebook

The response returned can be formatted as the following

For more information about facebook grapg API, please check http://developers.facebook.com/docs/api

$fb->post( $url,$args )

Send post request to facebook API, usually to post something

For more information about facebook grapg API, please check http://developers.facebook.com/docs/api

AUTHOR ^

Mahmoud A. Mehyar, <mamod.mehyar@gmail.com>

COPYRIGHT AND LICENSE ^

Copyright (C) 2010 by Mahmoud A. Mehyar

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.1 or, at your option, any later version of Perl 5 you may have available.

syntax highlighting: