0
votes

I'm trying to use the Facebook plugin from webtechnick with my CakePHP 1.3.10 app. I've followed all the directions to install it and have all the functionalities available:

  • Downloaded package and installed in app/plugins/facebook
  • Created app/config/facebook.php with my app's id, key and secret numbers, based on the example config file
  • Included $helpers = array('Facebook.Facebook') in my app_controller.php
  • Echoed the $this->Facebook->html() function in my layout (replcing the default html tag)
  • Echoed the $this->Facebook->init() function at the bottom of the layout, before

Then, I use this code in my view:

echo $this->Facebook->share('link'); 
echo $this->Facebook->like();   
echo $this->Facebook->comments();

But I only get the share button, not the like or comments. Am I missing any step? If I echo something inside the facebook helper like() function for example, it prints in in the view, so it's actually calling the function, but not generating the facbook element. Any ideas? I don't know what else to try, I believe I've followed all the steps...

----------UPDATE--------------------------

With Firebug I see this script error: FB.provide is not a function

The file where the error comes from is http://connect.facebook.net/es_ES/all.js, which I assume the plugin calls it. But since it's in Facebook's servers, what can I do about it? Does that mean there's a problem on their end? I don't see many more things I can do in my end. Any ideas?

4

4 Answers

1
votes

It appears the all.js file causes problems in both IE and Firefox. I'm using IE8 and Firefox 7.

After looking at the following...Stack Overflow Answer and Facebook Bug Report I was able to solve both. The fix for me was editing the facebook.php helper and adding the following...

IE Fix

FB.UIServer.setActiveNode = function(a,b){FB.UIServer._active[a.id]=b;}

Firefox Fix

window.FB = null;
FB = null;

Complete init() function

function init($options = array()){
    if(FacebookInfo::getConfig('appId')){
        $appId = FacebookInfo::getConfig('appId');
        $session = json_encode($this->Session->read('FB.Session'));
        $init = '<div id="fb-root"></div>';
        $init .=  $this->Html->scriptBlock(
            "
            window.fbAsyncInit = function() {
                FB.init({
                    appId   : '{$appId}',
                    session : {$session}, // don't refetch the session when PHP already has it
                    status  : true, // check login status
                    cookie  : true, // enable cookies to allow the server to access the session
                    xfbml   : true // parse XFBML
                });

                /* IE FIX */
                FB.UIServer.setActiveNode = function(a,b){FB.UIServer._active[a.id]=b;}
                /**********/

                // whenever the user logs in, we refresh the page
                FB.Event.subscribe('auth.login', function() {
                    window.location.reload();
                });
            };
            (function() {

                /* FIREFOX FIX */
                window.FB = null;
                FB = null;
                /**********/

                var e = document.createElement('script');
                e.src = document.location.protocol + '//connect.facebook.net/{$this->locale}/all.js';
                e.async = true;
                document.getElementById('fb-root').appendChild(e);
            }());
            ",
            $options
        );
        return $init;
    }
    else {
        return "<span class='error'>No Facebook configuration detected. Please add the facebook configuration file to your config folder.</span>";
    } 
}

A little late but I hope this helps someone!

1
votes

This may be due to the fact that Facebook deprecating FBML.

So use the normal html tag instead of $this->Facebook->html(); before the HEAD tag.

This works for me. Btw, it's becoming a pain to develop for Facebook lol. Cheers to being a developer, I think we will die young. >.<

"On Jan 1, 2012: FBML will no longer be supported on Platform. June 1, 2012: FBML apps will no longer work. " Read more about it here: http://developers.facebook.com/docs/reference/fbml/

1
votes

Put facebook directory into the app/plugins directory and put facebook.php from config folder of facebook directory into app/config folder and I am sure your problem will get solve immediately.

Thanks

0
votes
  • Go to: https://developers.facebook.com/apps then create new app.
  • In the "Select how your app integrates with Facebook" section: Tick website and input your site url.
  • Copy /plugin/Facebook/config/facebook.php.example to app/config/facebook.php , open facebook.php and modify your app id and your secret. That's all.