[Catalyst-commits] r12126 -
trunk/examples/CatalystAdvent/root/2009/pen
cosmincx at dev.catalyst.perl.org
cosmincx at dev.catalyst.perl.org
Tue Dec 1 19:24:06 GMT 2009
Author: cosmincx
Date: 2009-12-01 19:24:06 +0000 (Tue, 01 Dec 2009)
New Revision: 12126
Modified:
trunk/examples/CatalystAdvent/root/2009/pen/fbconnect.pod
Log:
- pod++ stuff.
Modified: trunk/examples/CatalystAdvent/root/2009/pen/fbconnect.pod
===================================================================
--- trunk/examples/CatalystAdvent/root/2009/pen/fbconnect.pod 2009-12-01 18:59:30 UTC (rev 12125)
+++ trunk/examples/CatalystAdvent/root/2009/pen/fbconnect.pod 2009-12-01 19:24:06 UTC (rev 12126)
@@ -1,8 +1,13 @@
=head1 FBConnect with Catalyst::Authentication::Credential::FBConnect
-L<Catalyst::Authentication::Credential::FBConnect> offers an easy way to grab the credential identifier from a user on Facebook.
-It uses L<WWW::Facebook::API>.
+L<Catalyst::Authentication::Credential::FBConnect> offers an easy way to grab the credential identifier, session key and session expires from a user on Facebook.
+Creaza un $c->user cu metodele:
+session_uid
+session_key
+session_expires
+
+
=head1 Instalation
L<Catalyst::Authentication::Credential::FBConnect> depends on:
@@ -19,8 +24,11 @@
=head1 Getting it done
-=begin pod::perl
+=begin pod::xhtml
+<p>
+
+<pre>
package MyApp;
__PACKAGE__->config( 'authentication' => {
@@ -62,11 +70,21 @@
data_type => 'integer',
is_auto_increment => 1,
},
+ email => {
+ data_type => 'varchar',
+ is_nullable => 1
+ },
+ password => {
+ data_type => 'varchar',
+ is_nullable => 1
+ },
credential_identifier => {
data_type => 'varchar',
+ is_nullable => 1
},
credential_source => {
data_type => 'varchar',
+ is_nullable => 1
},
);
@@ -89,8 +107,6 @@
my ($self, $c) = @_;
if( $c->authenticate( {}, 'facebook' ) ) {
- #$c->user->session_uid;
-
my $user = $c->model('DB::User')->find_or_create( {
credential_identifier => $c->user->session_uid,
credential_source => 'facebook',
@@ -106,17 +122,58 @@
1;
+</pre>
-=end pod::perl
+</p>
+=end pod::xhtml
+You can also assign a facebook account to an already existing account.
+
+=begin pod:xhtml
+
+<p><pre>
+
+#somewhere in a password required login: $c->authenticate( { email => $email, password => $password }, 'foo' );
+
+package MyApp::Controller::FBconnect;
+use strict;
+use warnings;
+
+sub assign : Path('/assign/facebook') {
+ my ($self, $c) = @_;
+
+ my $user = $c->user if $c->user_in_realm('foo');
+ if( $c->authenticate( {}, 'facebook' ) ) {
+ $user->update( {
+ credential_identifier => $c->user->session_uid,
+ credential_source => 'facebook',
+ } );
+
+ $c->authenticate( {
+ credential_identifier => $user->credential_identifier,
+ credential_source => 'facebook'
+ }, 'dbic' ) or die "Login failed";
+ }
+
+}
+
+</pre></p>
+
+
+=end pod:xhtml
+
+
This practicaly gets you the uid from Facebook. This can be used later on with L<WWW::Facebook::API>.
Here's some example code to actualy use L<WWW::Facebook::API>
-=begin pod::perl
+=begin pod::xhtml
+<p>
+
+<pre>
my $client = WWW::Facebook::API->new(
desktop => 0,
api_key => 'my_api_key'
@@ -133,10 +190,14 @@
my $friends = $client->friends->get(
uid => $c->user->credential_identifier
);
+</pre>
-=end pod::perl
+</p>
+=end pod::xhtml
+
+
More about this can be found in the L<WWW::Facebook::API> docs
More information about the Catalyst-commits
mailing list