Facebook
view release on metacpan or search on metacpan
lib/Facebook.pm view on Meta::CPAN
package Facebook;
BEGIN {
$Facebook::AUTHORITY = 'cpan:GETTY';
}
BEGIN {
$Facebook::VERSION = '0.102';
}
# ABSTRACT: Facebook SDK in Perl
use Moose;
use Carp qw/croak/;
use namespace::autoclean;
has desktop => (
isa => 'Bool',
is => 'ro',
required => 1,
lazy => 1,
default => sub { 0 },
);
has uid => (
isa => 'Maybe[Str]',
is => 'rw',
lazy => 1,
default => sub {
my $self = shift;
$self->signed->uid;
},
);
has app_id => (
isa => 'Maybe[Str]',
is => 'rw',
lazy => 1,
default => sub {
my $self = shift;
$self->signed->app_id;
},
);
has api_key => (
isa => 'Maybe[Str]',
is => 'rw',
lazy => 1,
default => sub { croak 'api_key is required' },
);
has secret => (
isa => 'Maybe[Str]',
is => 'rw',
lazy => 1,
default => sub {
my $self = shift;
$self->signed->secret;
},
);
has access_token => (
isa => 'Maybe[Str]',
is => 'ro',
lazy => 1,
default => sub {
my $self = shift;
$self->signed->access_token;
},
);
has access_token_secret => (
isa => 'Maybe[Str]',
is => 'ro',
lazy => 1,
default => sub {
my $self = shift;
$self->signed->access_token_secret;
},
);
has signed => (
isa => 'Facebook::Signed',
is => 'ro',
lazy => 1,
default => sub { croak 'signed values are required' },
predicate => 'has_signed',
);
has graph_class => (
isa => 'Str',
is => 'ro',
default => sub { 'Facebook::Graph' },
);
has graph_api => (
is => 'ro',
lazy => 1,
default => sub {
my $self = shift;
my $graph_class_file = $self->graph_class;
$graph_class_file =~ s/::/\//g;
require $graph_class_file.'.pm';
$self->graph_class->import;
$self->graph_class->new(
app_id => $self->app_id,
secret => $self->secret,
access_token => $self->access_token,
);
},
);
has rest_class => (
isa => 'Str',
is => 'ro',
required => 1,
default => sub { 'WWW::Facebook::API' },
);
has rest_api => (
is => 'ro',
lazy => 1,
default => sub {
my $self = shift;
my $rest_class_file = $self->rest_class;
$rest_class_file =~ s/::/\//g;
require $rest_class_file.'.pm';
$self->rest_class->import;
$self->rest_class->new(
desktop => $self->desktop ? 0 : 1,
api_key => $self->api_key,
secret => $self->secret,
);
},
);
sub graph {
my ( $self ) = @_;
$self->graph_api;
}
sub rest {
my ( $self ) = @_;
$self->rest_api;
}
1;
__END__
=pod
=head1 NAME
Facebook - Facebook SDK in Perl
=head1 VERSION
version 0.102
=head1 SYNOPSIS
use Facebook;
my $fb = Facebook->new(
app_id => $app_id,
api_key => $api_key,
secret => $secret,
);
use Facebook::Signed;
my $logged_in_fb = Facebook->new(
signed => Facebook::Signed->new(
secret => $secret,
facebook_data => $facebook_cookie_for_your_application_as_text,
),
app_id => $app_id,
secret => $secret,
api_key => $api_key,
);
# If you dont provide secret, it will try to fetch it from signed values
my $shorter_logged_in_fb = Facebook->new(
signed => Facebook::Signed->new(
secret => $secret,
facebook_data => $facebook_cookie_for_your_application_as_text,
),
app_id => $app_id,
( run in 0.640 second using v1.01-cache-2.11-cpan-13bb782fe5a )