views:

165

answers:

3

Hi overflowers,

I try to get the sfFacebookConnectPlugin to run by following the tutorial on the symfony homepage.

Everything seems well configured. But when I try to login with sfFacebookConnectAuth/signin. I get the form error "The username and/or password is invalid.".

I even don't know where to start with the debugging.

First Step could be to find out the right Application-Settings on the Facebook-Side (e.g. Post-Authorize Callback URL, Connect-URL or Canvas Callback URL)

I use symfony 1.4.5 doctrine with sfGuardDoctrinePlugin (on a live host with subdomain.)

Thx for your help.

A: 

It says on the plugin page that this plugin is only supported/stable up to Symfony 1.2. Might make sense to email the plugin author directly regarding 1.4 compatibility.

Tom
Yes I recognized it and it is very confusing, but the tutorial I was talking about is for Symfony 1.4 so it should be compatible.
Wondering if there are so few developers using this Plugin (or have problems with it) :-/
Might be because it says 1.2 on the main page. Any newcomers to Symfony would start with 1.4 and lots of people are already waiting for 2.0.
Tom
A: 

I found that page: http://burgiblog.com/2009/09/18/developing-facebook-applications-with-symfony/ now it works, I changed three things after reading the tutorial:

  • modules/sfFacebookConnectAuth/config/security.yml: Use "false" instead of "off"
  • I added "callback_url" in apps/frontend/config/app.yml
  • And I used the facebook action in the tutorial

I need to find out, what the problem exactly was. And I need to enhance some things to the plugin. E.g. saving the user data to my profile class etc. (Now I saves a cryptic username instead of the right FB username.)

A: 

Hi,

I'm having some problems with sfFacebookConnectPlugin. I tried replicating the simple example from http://burgiblog.com/2009/09/18/developing-facebook-applications-with-symfony/ . And calling the index page, I get redirected to the facebook authentication page but after logging in, I do not get redirected back. I stay logged into facebook only. What am I doing wrong?

Thanks.

This is my code:

[/frontend/config/app.yml]

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

  # It is highly recommended to use a js framework if you want a correct experience in IE

  sf_guard_plugin:
    profile_class: sfGuardUserProfile
    profile_field_name: user_id
    profile_facebook_uid_name: facebook_uid # WARNING this column must be of type bigint ! 100000398093902 is a valid uid for example !
    profile_email_name: email
    profile_email_hash_name: email_hash

  facebook_connect:
    load_routing:     true
    user_permissions: []


[layout.php]

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" xmlns:fb="http://www.facebook.com/2008/fbml"&gt;
<head>
<?php use_helper('sfFacebookConnect') ?>
<?php include_http_metas() ?>
<?php include_metas() ?>
<?php include_title() ?>
<link rel="shortcut icon" href="/favicon.ico" />
</head>
<body>

<?php echo $sf_content ?>

<?php include_bottom_facebook_connect_script(); ?>

</body>
</html>



[actions.class.php]

<?php

/**
 * facebook actions.
 *
 * @package
 * @subpackage facebook
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 12479 2008-10-31 10:54:40Z fabien $
 */
class homeActions extends sfActions
{
    /**
     * Executes index action
     *
     * @param sfRequest $request A request object
     */

    public function executeIndex(sfWebRequest $request)
    {
        sfFacebook::requireLogin();
        //get the user object
        $user = $this->getUser();

        // facebook user id
        $this->fb_uid = $user->getCurrentFacebookUid();
        // get or create user based on fb_uid
        $fb_user = sfFacebook::getOrCreateUserByFacebookUid($this->fb_uid);
    }
}



[indexSuccess.php]

<?php if ($sf_user->isFacebookConnected()): ?>

<fb:serverfbml style="width: 740px;">
    <script type="text/fbml">
        <fb:fbml>
            <fb:request-form target="_top" action="[where to redirect after invite]" method="post" type="[name of your app]" content="[text the user will receive]&lt;fb:req-choice url=&quot;http://apps.facebook.com/[your app]/&quot; label=&quot;Accept!&quot;  " image="" invite="true">
                <fb:multi-friend-selector cols="4" actiontext="[some text above the invite form]" />
            </fb:request-form>
        </fb:fbml>
    </script>
</fb:serverfbml>

<?php else: ?>
<p>Ooops?</p>
<br />
<?php endif; ?>
srus
Your callback URL must be reachable from outside. Localhost won't work at all. Upload your code to a server, and change the callback URL.