24 August 2009

A Facebook Connect plugin for symfony

As promised during the last symfony live conference, I finally release my current work on a Facebook Connect Plugin for symfony. It is inspired by the good sfFacebookPlugin by Jonathan Todd, which has however been unmaintained for quite some time. Since Facebook’s platform is evolving every week and my focus was not on the Facebook platform but on the Facebook Connect functionality, I decided to create this new plugin.

It is for the moment VERY beta. It is used in two projects, http://www.allomatch.com which is a symfony 1.0/propel project and another project on symfony 1.2/doctrine. It is therefore compatible with both Doctrine and Propel. However some issues remain concerning 1.0 and 1.2 versions regarding some options, the tasks for example.

For the installation, the README is a good start but FAR from complete. I invite you to browse through the code to understand the logic and comment on this post if you have any question regarding installation. This will force me to improve the README.

I intend to improve the documentation in the very near future, so if you are not in a hurry, please wait. However I have already received dozens of mails concerning the current status, so I release it for those who need to start a project using Facebook Connect right now.

Here is the link to the plugin:

http://www.symfony-project.org/plugins/sfFacebookConnectPlugin

And here the presentation made at the sflive conference:

http://www.symfony-live.com/pdf/sflive09fr/theodo-symfony-facebook.pdf

Filed under : sfFacebookConnectPlugin, symfony — Fabrice Bernhard @ 12 h 02 min

22 Comment »

  1. Oncle Tom say :
    24 August 2009

    Ah ah awesome! I was just starting today an FB Connect integration on a SF project :-) just a huge thanks!

    13 h 08 min

  2. Matthieu say :
    24 August 2009

    Great work Fabrice,

    Thanks for sharing.

    Matt.

    17 h 34 min

  3. Rich say :
    25 August 2009

    Hello, does handle or intend to handle the “invite friends” stuff, too ?

    11 h 23 min

  4. COil say :
    25 August 2009

    Super sympa. :) Good job !

    12 h 37 min

  5. Oncle Tom say :
    25 August 2009

    I’ve contributed a first patch for restrictive routing purpose.

    http://trac.symfony-project.org/ticket/7065

    14 h 13 min

  6. Fabrice Bernhard say :
    25 August 2009

    commited !

    It is a very good remark and I am happy to show contributions can be very quick. Just a small reserve, I am quite sure it is not 1.0 compatible, but since you thought about making it optional it in the app.yml file, it should not pose any problem to anybody.

    Thanks for the very good contribution !

    14 h 20 min

  7. Oncle Tom say :
    26 August 2009

    Yep I’m not sure the routing method works for 1.0 (I use the 1.2 one) but it can be overridden in all cases.

    One other remark: if a Profile attribute is “notnull: true”, the getOrCreate method will throw an exception because it won’t fill the mandatory fields.

    The Auth process is far from simple as some sites will require an account creation + FB linking, some account creation with FB + account profile completion, some others, just FB linking.

    11 h 29 min

  8. Oncle Tom say :
    27 August 2009

    Your latest commit breaks in the GuardAdapter as it call to sfMixer which is not consistent with the usage of Doctrine.

    17 h 16 min

  9. Jean say :
    4 September 2009

    Hey everybody,
    I’m experiencing an error while executing BasesfFacebookConnectAuthActions:executeSignin()

    I guess the error comes from sfFacebookDoctrineGuardAdapter::retrieveSfGuardUserByFacebookUid() most particularly this line :

    ->innerJoin(‘u.Profile p’)

    I work remotly to test FB Connect, and the error log is :
    Unknown relation alias Profile, referer: http://www.myserver.com/

    Please help !
    Regards

    16 h 02 min

  10. Fabrice Bernhard say :
    6 September 2009

    Tom: I have comitted the solution you sent me by mail.

    Jean: Damien Alexandre kindly sent me a patch to be able to configure the name of the “Profile” relationship. You will be able to configure it as soon as i commit it. Remember the plugin is still heavily in development !

    14 h 36 min

  11. Travis say :
    8 September 2009

    Fabrice, is it possible to prompt for extended permissions when authenticated the user for the first time?

    19 h 58 min

  12. Kieu Anh Tuan say :
    3 November 2009

    Hi,
    Really great piece of work. I’ve played around with the plugin and it works really well.

    I have some questions for you, when do you plan to complete the documentation? will mobile-enabled site be supported by sfFacebookConnect?

    Thanks

    14 h 20 min

  13. Fabrice Bernhard say :
    10 November 2009

    Kieu Anh Tuan: a very thorough documentation is almost done! Should unfortunately be online end of december, but it will explain step by step how to configure your project for a Facebook app or Facebook Connect and also cover the most common problems Facebook developers face.

    As for mobile-enabled sites, this is indeed planned but no fixed schedule yet on my side. You are welcome to contribute yourself if you think you will work on that soon :-)

    21 h 41 min

  14. Samuel say :
    7 January 2010

    I get 3 warnings saying that “call-time pass-by-reference” is deprecated:

    line 215 in plugins/sfFacebookConnectPlugin/lib/sfFacebookGuardAdapter.class.php
    lines 78 and 109 in plugins/sfFacebookConnectPlugin/lib/sfFacebookConnect.class.php

    Seems like it is a problem as of PHP 5.3.0. Does removing the &-symbol break anything? Thanks.

    9 h 41 min

  15. goutham say :
    24 January 2010

    when can we expect a 1.4 version of this.

    1 h 29 min

  16. Xavier P say :
    9 October 2010

    Hi!
    i’m starting the developpement of a website and i’m very interested by your facebook connect plugin but can i use it with Symfony 1.4 ? Is it compatible ?

    If someone have some experience about that i’m interested !

    Thanks by advance.

    Xavier

    23 h 35 min

  17. Fabrice Bernhard say :
    27 October 2010

    I finally packaged the github version of the plugin, so you can now install automatically the symfony 1.4-compatible version !

    18 h 13 min

  18. mandoy say :
    2 November 2010

    hi fabrice,
    ive installed your sfFacebookConnectPlugin in my app. However,

    after i clicked the ‘connect with facebook’ button it will redirected to this page ‘http://local.cdi.com/frontend_dev.php/fb-connect/signin’
    and i received an error like this

    Undefined property: Facebook::$api_client in D:\xampp\htdocs\cdi\portal\plugins\sfFacebookConnectPlugin\lib\sfFacebookConnect.class.php on line 30
    Fatal error: Call to a member function fql_query() on a non-object in D:\xampp\htdocs\cdi\portal\plugins\sfFacebookConnectPlugin\lib\sfFacebookConnect.class.php on line 30

    all:
    facebook:
    api_key: xxx
    api_secret: xxx
    api_id: xxx
    redirect_after_connect: false
    redirect_after_connect_url: ”
    connect_signin_url: ’sfFacebookConnectAuth/signin’
    callback_url: ‘http://localhost’
    app_url: ‘/my-app’
    guard_adapter: ~
    js_framework: none # none, jQuery or prototype.



    I enabled the modules
    enabled_modules: [default, sfFacebookConnectAuth]

    I think the Facebook class is not loaded properly. Do i have to instantiate the Facebook class again?
    Or have i miss something on my settings.

    Any help is highly appreciated.
    Regards
    mandoy

    10 h 44 min

  19. Sela say :
    15 November 2010

    for the newer version of symfony I changed the security.yml in the module sfFacebookConnectAuth from off to false otherwise when click the facebook connect button it forwards to the login page and doesn’t perform the action signin.

    1 h 41 min

  20. Michal CZ say :
    1 December 2010

    This will make my next work very simple, THX!!

    11 h 45 min

  21. MrMoins say :
    29 March 2011

    Hello,
    le plugin a bien évoluer apparement depuis le début, mais malheureusement il manque de documentation, savez-vous ou je peux trouver des explications pour utiliser ce plugin au mieux ?
    merci

    22 h 27 min

  22. Nikolay Traykov say :
    4 October 2011

    Like Travis I would like to know, how can I prompt the user for extended permissions on login?

    Travis, did you figured out how this happen?

    Cheers ;)

    8 h 32 min


Leave an answer