Facebook - Facebook SDK in Perl


Facebook documentation Contained in the Facebook distribution.

Index


Code Index:

NAME

Top

Facebook - Facebook SDK in Perl

VERSION

Top

version 0.102

SYNOPSIS

Top

  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,
    api_key => $api_key,
  );

  # You need to have Facebook::Graph installed so that this works
  my $gettys_facebook_profile = $fb->graph->query
    ->find(100001153174797)
    ->include_metadata
    ->request
    ->as_hashref;

DESCRIPTION

Top

If you are new to Facebook application development in Perl please read Facebook::Manual!

This package reflects an instance for your application. Depending on what API of it you use, you require to install the needed distributions or provide alternative packages yourself.

METHODS

Top

$obj->graph

Arguments: None

Return value: Object

If you want to use this, you need to install Facebook::Graph!

Returns an instance of the graph_class (by default this is Facebook::Graph)

$obj->rest

Arguments: None

Return value: Object

If you want to use this, you need to install WWW::Facebook::API!

Returns an instance of the rest_class (by default this is WWW::Facebook::API)

METHODS

Top

LIMITATIONS

Top

TROUBLESHOOTING

Top

AUTHORS

Top

COPYRIGHT AND LICENSE

Top


Facebook documentation Contained in the Facebook distribution.

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__