I just discovered this plugin,
Drag Drop Plugin - jQuery
Then you simply call this function, either with the shutter onlogin = "" facebook connect button, or with a jquery function:public static function updateSfGuardUserWithFacebookAccount ($ sfGuardUser ) {; sfGuardUserProfile $ = $ sfGuardUser -> getProfile ();$ info = sfFacebook: getFacebookApi () -> ; users_getInfo ( $sfGuardUserProfile ->getFacebookUid(), array( "first_name", "last_name", "username", "birthday_date", "email_hashes", "proxied_email", "sex", "pic", "pic_small", "relationship_status", "current_location", "activities", "interests", "music", "tv", "movies", "books", "website" )); $sfGuardUserProfile ->setFirstName( $infos [0]["first_name"]); $sfGuardUserProfile -> setLastName ($ info [0] ["last_name"]);$ sfGuardUserProfile -> setEmailHash (serialize ($ info [0] ["email_hashes "]));$ sfGuardUserProfile -> setEmail ($ info [0] [" proxied_email "]);; $ sfGuardUserProfile -> setBirthdayDate ($ info [0] ["birthday_date"]);$ sfGuardUserProfile -> setSex ($ info [0] ["sex"]);$ sfGuardUserProfile -> setPic ($ info [0] ["pic"]);$ sfGuardUserProfile -> setPicSmall ($ info [0] [" pic_small "]);$ sfGuardUserProfile -> SetRelationshipStatus ($ info [0] ["relationship_status"]);$ sfGuardUserProfile -> setActivities ($ info [0] ['activities "]);$ sfGuardUserProfile -> setInterests ($ info [0] ['interests']);; $ sfGuardUserProfile -> setMusic ($ info [0] ["music"]);$ sfGuardUserProfile -> setTv ($ info [0] ["tv"]);$ sfGuardUserProfile -> setMovies ($ info [0] ["movies"]);$ sfGuardUserProfile -> setBooks ($ info [0] ['books "]);$ sfGuardUserProfile -> setWebsite ($ info [0] ["website"]);$ sfGuardUserProfile -> save ();return true ;}
updateProfileWithFacebook function () {$
. ajax ({
url: '/ sfFacebookConnectAuth / UpdateGuardWithFBProfile'
success: function (profile) {$ (". Profile"). Html (profile);
makeEditableField ();},
error: function (e) {alert ("An error occurred. We can not contact the Facebook servers. Please accept our apologies for this inconvenience and try later. "e);}}
);}
You can find the list of recoverable information here
Then you simply call this function, either with the shutter onlogin = "" facebook connect button, or with a jquery function:public static function updateSfGuardUserWithFacebookAccount ($ sfGuardUser ) {; sfGuardUserProfile $ = $ sfGuardUser -> getProfile ();$ info = sfFacebook: getFacebookApi () -> ; users_getInfo ( $sfGuardUserProfile ->getFacebookUid(), array( "first_name", "last_name", "username", "birthday_date", "email_hashes", "proxied_email", "sex", "pic", "pic_small", "relationship_status", "current_location", "activities", "interests", "music", "tv", "movies", "books", "website" )); $sfGuardUserProfile ->setFirstName( $infos [0]["first_name"]); $sfGuardUserProfile -> setLastName ($ info [0] ["last_name"]);$ sfGuardUserProfile -> setEmailHash (serialize ($ info [0] ["email_hashes "]));$ sfGuardUserProfile -> setEmail ($ info [0] [" proxied_email "]);; $ sfGuardUserProfile -> setBirthdayDate ($ info [0] ["birthday_date"]);$ sfGuardUserProfile -> setSex ($ info [0] ["sex"]);$ sfGuardUserProfile -> setPic ($ info [0] ["pic"]);$ sfGuardUserProfile -> setPicSmall ($ info [0] [" pic_small "]);$ sfGuardUserProfile -> SetRelationshipStatus ($ info [0] ["relationship_status"]);$ sfGuardUserProfile -> setActivities ($ info [0] ['activities "]);$ sfGuardUserProfile -> setInterests ($ info [0] ['interests']);; $ sfGuardUserProfile -> setMusic ($ info [0] ["music"]);$ sfGuardUserProfile -> setTv ($ info [0] ["tv"]);$ sfGuardUserProfile -> setMovies ($ info [0] ["movies"]);$ sfGuardUserProfile -> setBooks ($ info [0] ['books "]);$ sfGuardUserProfile -> setWebsite ($ info [0] ["website"]);$ sfGuardUserProfile -> save ();return true ;}
updateProfileWithFacebook function () {$
. ajax ({
url: '/ sfFacebookConnectAuth / UpdateGuardWithFBProfile'
success: function (profile) {$ (". Profile"). Html (profile);
makeEditableField ();},
error: function (e) {alert ("An error occurred. We can not contact the Facebook servers. Please accept our apologies for this inconvenience and try later. "e);}}
);}
You can find the list of recoverable information here
sfGuard BEFORE INSTALLING INCLUDE FACEBOOK CONNECTOnce that is done, you install the plugin sfFacebookConnect
Then you create a application on Facebook / developpers
svn co http://svn.symfony-project.com/plugins/sfFacebookConnectPlugin/trunk sfFacebookConnectPlugin
mon.url / / / must end with a slashBase Domain:
mon.urlCAUTION: This is selected in a certain way. It takes several things: that your mon.url either online (no particular file to be included on the online site, Facebook is going to ping, that is). If you want, like me, programming and testing the plugin locally, you can modify your hosts file (located here in linux: / etc / hosts) and add the line 127.0.0.1 local . mon.url
all:
. settings:
enabled_modules: [default, sfGuardAuth, sfFacebookConnectAuth]
login_module: BasesfFacebookConnectAuthActions
LOGIN_ACTION: executeAjaxSigninThen edit your app.yml:
all:
facebook:
api_key: votre_api_key
api_secret: votre_api_secret
api_id: votre_app_id
redirect_after_connect: false
redirect_after_connect_url: ''
connect_signin_url: 'sfFacebookConnectAuth/signin'
app_url: '/my-app'
guard_adapter: ~
js_framework: jQuery
sf_guard_plugin:
profile_class: sfGuardUserProfile
profile_field_name: user_id
profile_facebook_uid_name: facebook_uid
profile_email_name: email
profile_email_hash_name: email_hash
facebook_connect:
load_routing: true
user_permissions: []
sfGuardUserProfile:
tableName: sf_guard_user_profile
columns:
user_id: { type: integer(4), notnull: true }
first_name: { type: string(30) }
last_name: { type: string(30) }
facebook_uid: { type: string(20) }
email: { type: string(255) }
email_hash: { type: string(255) }
birthday_date : { type: string(255) }
sex: { type: string(255) }
pic: { type: string(255) }
pic_small: { type: string(255) }
relationship_status : { type: string(255) }
current_location : { type: string(255) }
activities : { type: string(255) }
interests : { type: string(255) }
music : { type: string(255) }
tv : { type: string(255) }
movies : { type: string(255) }
books : { type: string(255) }
local : { type: string(255) }
books : { type: string(255) }
website : { type: string(255) }
indexes:
facebook_uid_index:
fields: [facebook_uid]
unique: true
email_index:
fields: [email]
unique: true
email_hash_index:
fields: [email_hash]
unique: true
relations:
sfGuardUser:
type: one
foreignType: one
class: sfGuardUser
local: user_id
foreign: id
onDelete: cascade
foreignAlias: ProfileObviously, we must tell Doctrine to build the new table and Relationships :
symfony doctrine: build - all - and-save - no-confirmationThen go to / apps / frontend / lib / myUser.class.php
myUser {} extends sfFacebookUserWell, the plugin is finished.
\u0026lt;script type = "text / javascript" src = "/ sfFacebookConnectPlugin / js / animation / animation . js "> \u0026lt;/ script>\u0026lt;? php use_helper ('sfFacebookConnect');>\u0026lt;? php include_bottom_facebook_connect_script ();?>
At this level, a simple click on the button, check whether the user is already logged on to facebook otherwise he will propose to enter their credentials. If identified correctly in the form facebook, it is immediately identified on your site.\u0026lt; php if (! $ sf_user-> isAuthenticated ()) {?>\u0026lt;fb:login-button v="2" size="medium"> Log with Facebook \u0026lt;/ fb: login-button>\u0026lt;? php} else {echo "hello";}?>
sfGuard BEFORE INSTALLING INCLUDE FACEBOOK CONNECTOnce that is done, you install the plugin sfFacebookConnect
Then you create a application on Facebook / developpers
svn co http://svn.symfony-project.com/plugins/sfFacebookConnectPlugin/trunk sfFacebookConnectPlugin
mon.url / / / must end with a slashBase Domain:
mon.urlCAUTION: This is selected in a certain way. It takes several things: that your mon.url either online (no particular file to be included on the online site, Facebook is going to ping, that is). If you want, like me, programming and testing the plugin locally, you can modify your hosts file (located here in linux: / etc / hosts) and add the line 127.0.0.1 local . mon.url
all:
. settings:
enabled_modules: [default, sfGuardAuth, sfFacebookConnectAuth]
login_module: BasesfFacebookConnectAuthActions
LOGIN_ACTION: executeAjaxSigninThen edit your app.yml:
all:
facebook:
api_key: votre_api_key
api_secret: votre_api_secret
api_id: votre_app_id
redirect_after_connect: false
redirect_after_connect_url: ''
connect_signin_url: 'sfFacebookConnectAuth/signin'
app_url: '/my-app'
guard_adapter: ~
js_framework: jQuery
sf_guard_plugin:
profile_class: sfGuardUserProfile
profile_field_name: user_id
profile_facebook_uid_name: facebook_uid
profile_email_name: email
profile_email_hash_name: email_hash
facebook_connect:
load_routing: true
user_permissions: []
sfGuardUserProfile:
tableName: sf_guard_user_profile
columns:
user_id: { type: integer(4), notnull: true }
first_name: { type: string(30) }
last_name: { type: string(30) }
facebook_uid: { type: string(20) }
email: { type: string(255) }
email_hash: { type: string(255) }
birthday_date : { type: string(255) }
sex: { type: string(255) }
pic: { type: string(255) }
pic_small: { type: string(255) }
relationship_status : { type: string(255) }
current_location : { type: string(255) }
activities : { type: string(255) }
interests : { type: string(255) }
music : { type: string(255) }
tv : { type: string(255) }
movies : { type: string(255) }
books : { type: string(255) }
local : { type: string(255) }
books : { type: string(255) }
website : { type: string(255) }
indexes:
facebook_uid_index:
fields: [facebook_uid]
unique: true
email_index:
fields: [email]
unique: true
email_hash_index:
fields: [email_hash]
unique: true
relations:
sfGuardUser:
type: one
foreignType: one
class: sfGuardUser
local: user_id
foreign: id
onDelete: cascade
foreignAlias: ProfileObviously, we must tell Doctrine to build the new table and Relationships :
symfony doctrine: build - all - and-save - no-confirmationThen go to / apps / frontend / lib / myUser.class.php
myUser {} extends sfFacebookUserWell, the plugin is finished.
\u0026lt;script type = "text / javascript" src = "/ sfFacebookConnectPlugin / js / animation / animation . js "> \u0026lt;/ script>\u0026lt;? php use_helper ('sfFacebookConnect');>\u0026lt;? php include_bottom_facebook_connect_script ();?>
At this level, a simple click on the button, check whether the user is already logged on to facebook otherwise he will propose to enter their credentials. If identified correctly in the form facebook, it is immediately identified on your site.\u0026lt; php if (! $ sf_user-> isAuthenticated ()) {?>\u0026lt;fb:login-button v="2" size="medium"> Log with Facebook \u0026lt;/ fb: login-button>\u0026lt;? php} else {echo "hello";}?>
\u0026lt;?
php class extends sfGuardAuthComponents sfComponents
{
public function executeSideSignin ($ request) {
$ Class = sfConfig:: get ('app_sf_guard_plugin_signin_form', 'sfGuardFormSignin');
$ this-> signinForm = new $ class ();}
}
? >
\u0026lt;h2> Identification Form \u0026lt;/ h2>; include_component ('sfGuardAuth', 'sideSignin');>
\u0026lt;form id = "signinForm" action = "\u0026lt;? php echo url_for('@sf_guard_signin') ?>" method="post" class="clearfix">
<div id="signinFields">
<label for="signin_username">Login</label>
<input type="text" name="signin[username]" id="signin_username" />
<br />
<label for="signin_password">Mot de passe</label>
<input type="password" name="signin[password]" id="signin_password" />
<br />
<input type = "checkbox" name = "contemporary design [remember]," id = "signin_remember" />
\u0026lt;Label for="signin_remember"> The souvenir de moi \u0026lt; ; / label>
\u0026lt;/ div> \u0026lt;div
id="signinSubmit">
\u0026lt; ? php echo $ signinForm-> renderHiddenFields ();
?>
\u0026lt;! - A href ="#"> Forgot your password? \u0026lt;/ A> 'SideSignin');
", cache and refresh the page ...
To test whether the user is already authenticated, it uses this function:
if (! $ Sf_user-> isAuthenticated ())
\u0026lt;?
php class extends sfGuardAuthComponents sfComponents
{
public function executeSideSignin ($ request) {
$ Class = sfConfig:: get ('app_sf_guard_plugin_signin_form', 'sfGuardFormSignin');
$ this-> signinForm = new $ class ();}
}
? >
\u0026lt;h2> Identification Form \u0026lt;/ h2>; include_component ('sfGuardAuth', 'sideSignin');>
\u0026lt;form id = "signinForm" action = "\u0026lt;? php echo url_for('@sf_guard_signin') ?>" method="post" class="clearfix">
<div id="signinFields">
<label for="signin_username">Login</label>
<input type="text" name="signin[username]" id="signin_username" />
<br />
<label for="signin_password">Mot de passe</label>
<input type="password" name="signin[password]" id="signin_password" />
<br />
<input type = "checkbox" name = "contemporary design [remember]," id = "signin_remember" />
\u0026lt;Label for="signin_remember"> The souvenir de moi \u0026lt; ; / label>
\u0026lt;/ div> \u0026lt;div
id="signinSubmit">
\u0026lt; ? php echo $ signinForm-> renderHiddenFields ();
?>
\u0026lt;! - A href ="#"> Forgot your password? \u0026lt;/ A> 'SideSignin');
", cache and refresh the page ...
To test whether the user is already authenticated, it uses this function:
if (! $ Sf_user-> isAuthenticated ())