[Catalyst-commits] r7143 - in
Catalyst-Plugin-Authentication-Credential-Facebook/0.01/lib/Catalyst:
. Model
jshirley at dev.catalyst.perl.org
jshirley at dev.catalyst.perl.org
Mon Nov 19 21:22:05 GMT 2007
Author: jshirley
Date: 2007-11-19 21:22:05 +0000 (Mon, 19 Nov 2007)
New Revision: 7143
Added:
Catalyst-Plugin-Authentication-Credential-Facebook/0.01/lib/Catalyst/Model/
Catalyst-Plugin-Authentication-Credential-Facebook/0.01/lib/Catalyst/Model/Facebook.pm
Log:
Adding the facebook model
Added: Catalyst-Plugin-Authentication-Credential-Facebook/0.01/lib/Catalyst/Model/Facebook.pm
===================================================================
--- Catalyst-Plugin-Authentication-Credential-Facebook/0.01/lib/Catalyst/Model/Facebook.pm (rev 0)
+++ Catalyst-Plugin-Authentication-Credential-Facebook/0.01/lib/Catalyst/Model/Facebook.pm 2007-11-19 21:22:05 UTC (rev 7143)
@@ -0,0 +1,73 @@
+package Catalyst::Model::Facebook;
+
+use strict;
+use warnings;
+use base 'Catalyst::Model';
+
+use WWW::Facebook::API;
+
+__PACKAGE__->mk_accessors(qw/fb/);
+
+=head1 NAME
+
+Catalyst::Model::Facebook - Catalyst Model
+
+=head1 DESCRIPTION
+
+Catalyst Model for facebook access, requires the usage of
+L<Catalyst::Plugin::Authentication::Credential::Facebook>
+
+=head1 METHODS
+
+=head2 COMPONENT
+
+=cut
+
+sub COMPONENT {
+ my $self = shift->NEXT::COMPONENT(@_);
+
+ my $fb = WWW::Facebook::API->new(
+ api_key => $self->{api_key},
+ secret => $self->{secret},
+ debug => $self->{debug}
+ );
+ $fb->app_path( $self->{app_path} ) if $self->{app_path};
+
+ $self->fb($fb);
+
+ return $self;
+}
+
+sub ACCEPT_CONTEXT {
+ my ( $self, $c ) = @_;
+
+ if ( $c->req->params->{fb_sig} ) {
+ $self->fb->canvas->validate_sig( $c->req );
+ }
+ if ( $c->req->params->{auth_token} ) {
+ $self->fb->get_session( $c->req->params->{auth_token} );
+ }
+ $c->log->debug("Facebook params: " . $c->session->{fb_params}) if $c->debug;
+ if ( my $p = $c->session->{fb_params} ) {
+ $c->log->_dump($p) if $c->debug;
+ $self->fb->session(
+ uid => $p->{user},
+ key => $p->{session_key},
+ expires => $p->{expires}
+ );
+ }
+ return $self->fb;
+}
+
+=head1 AUTHOR
+
+J. Shirley <jshirley at gmail.com>
+
+=head1 LICENSE
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+1;
More information about the Catalyst-commits
mailing list