Monday, March 15, 2010

Delayed Vaccination Schedule Toronto

[symfony] [FACEBOOK] propose to identify visitors with a single click: FACEBOOK CONNECT

Connect to a site click is so convenient! No need for your users to spend 2 minutes to complete the registration form and go click on the link in the email received confirmation ball blah! We knew
OpenID which already allowed to do that, however, OpenID does not speak to many people while Facebook! omiprésent and is completely on the web.

Facebook thinks of us, the developers of 2.0 sites for us to make this task possible.
symfony thinks of us, lazy developers, for us to make this task easy and complete!

also before installing our famous plugin, you must have installed the plugin sfDoctrineGuard (also works with other version of sfGuard)
sfGuard BEFORE INSTALLING INCLUDE FACEBOOK CONNECT
Once that is done, you install the plugin sfFacebookConnect
For other (more) information, you can visit the page Plugin sfFacebook





  svn co http://svn.symfony-project.com/plugins/sfFacebookConnectPlugin/trunk sfFacebookConnectPlugin  
Then you create a application on Facebook / developpers
You must complete the following fields:
Connect Url: http://
mon.url / / / must end with a slash
Base Domain:
mon.url
CAUTION: 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
So you keep your internet access to your online site and you'll have access to your local site with the address local. mon.url . Obviously, your virtual host must be functional but it I do not do it for you.

Once the application is created, we will ensure that our config files allows the plugin to be used: In the file
settings.yml add sfFacebookConnectAuth line enabled_modules:

all:
. settings:
enabled_modules: [default, sfGuardAuth, sfFacebookConnectAuth]
login_module: BasesfFacebookConnectAuthActions
LOGIN_ACTION: executeAjaxSignin
Then 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: []

Then go to the file / plugins / sfDoctrineGuardPlugin / config / doctrine / schema.yml
So that we can store the profile information of the new user, you will have a new table in the database, table and link it with sf_guard_user_profile table sf_guard_user ... So
changes to:


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: Profile
Obviously, we must tell Doctrine to build the new table and Relationships :
symfony doctrine: build - all - and-save - no-confirmation
Then go to / apps / frontend / lib / myUser.class.php
extend the class and made class
myUser {} extends sfFacebookUser
Well, the plugin is finished.
USE NOW!
I guess and hope that you are using a layout with Facebook Connect, the use of layout greatly facilitates the integration of the plugin. Open your
/ apps / frontend / templates / layout.php
Insert these lines in the head tag:

\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 ();?>

Then we want to provide a link to the user to connect 1-click to our site.
So we will verify that the user is not connected to the site to offer him this button: Also in
layout because it is an element that vraissemblablement, we want to see on each page:

\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";}
?>
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.
And if we will see in the database, we see a new user named Facebook-012345678 has been created and it also has a profile. But there
(Surprise! Ho!) The profile is blank. Only the uid is recovered.


I have long sought a solution but in fact it sounds logical. We do not know in advance what you want to recover for your application and database is said that you only want to connect a user.
But I want to get a lot more than that, that's why I created a template for sf_guard_user_profile with all these fields (sex, etc. ...). brithday_date


To do this, you can follow this tutorial: Retrieve user information FacebookConnect
http://www.symfony-project.org/more-with-symfony/1_4/fr/12-Developing Facebook-for-
http://blog.fruitsoftware.com/2010/01/facebook-connect-friends-et-autres-plaisirs/

0 comments:

Post a Comment