To retrieve user information when registering to your site or by pressing a button to automatically fill in my profile " must create a function that will do that for us.
I put this function in the class sfFacebook is for me the most logical
Enjoy!
I put this function in the class sfFacebook is for me the most logical
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
Enjoy!
0 comments:
Post a Comment