Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Catalyst::Model::Facebook;
- use Moose;
- use WWW::Facebook::API;
- extends 'Catalyst::Model';
- with 'Catalyst::Component::InstancePerContext';
- has 'appid' => (
- is => 'rw',
- isa => 'Str',
- required => 1
- );
- has 'api_key' => (
- is => 'rw',
- isa => 'Str',
- required => 1
- );
- has 'secret' => (
- is => 'rw',
- isa => 'Str',
- required => 1
- );
- sub build_per_context_instance {
- my ( $self, $c ) = @_;
- my $client = WWW::Facebook::API->new(
- api_key => $self->api_key,
- app_id => $self->appid,
- desktop => 0,
- secret => $self->secret
- );
- my $params = $c->req->params;
- my $fb_params = $client->canvas->get_fb_params( $c->req );
- if ( $params->{'auth_token'} ) {
- $client->auth->get_session( $params->{'auth_token'} );
- }
- if ( $fb_params->{session_key} ) {
- $client->session_key( $fb_params->{session_key} );
- }
- return $client;
- }
- no Moose;
- __PACKAGE__->meta->make_immutable;
Add Comment
Please, Sign In to add comment