Integrating Facebook into your CakePHP application. Complete step by step from bake, Facebook application creation, Facebook configuration, to Facebook Connect. Learn how to easily add comments to any page and allow your users to register with their Facebook credentials.
Discusses the migration strategy and development process the core team is undergoing to migrate away from PHP4 and provide some of the more interesting benefits that come with PHP5 only support in the CakePHP 2.0 branch.
I have trouble when following your tutorial, I get this error:
Notice (8): Undefined index: appId [APP\plugins\facebook\vendors\facebook\src\base_facebook.php, line 213]
Notice (8): Undefined index: secret [APP\plugins\facebook\vendors\facebook\src\base_facebook.php, line 214]
Notice (8): Undefined property: Facebook::$table [CORE\cake\libs\model\model.php, line 666]
I am able to login, the error first occured when I tried to implement Auth.
i'm trying to follow the instructions bu i'm coming across with errors.
my application already has login and AppController when i input var $helpers = array('Facebook.Facebook'); into appcontroller there is a error.
here is the error which is displayed :
Warning (4096): Argument 1 passed to Helper::__construct() must be an instance of View, none given, called in /Users/emrahgul/Sites/evento/app/Plugin/Facebook/views/helpers/facebook.php on line 43 and defined [CORE/Cake/View/Helper.php, line 144]
Notice (8): Undefined variable: View [CORE/Cake/View/Helper.php, line 145]
Notice (8): Undefined variable: View [CORE/Cake/View/Helper.php, line 146]
Notice (8): Trying to get property of non-object [CORE/Cake/View/Helper.php, line 146]
here is the appcontoller
class AppController extends Controller {
var $uses = array('Messages.Message', 'Settings', 'User');
var $components = array('Auth', 'Session');
var $helpers = array('Html', 'Form', 'Js', 'Session', 'Facebook.Facebook');
can some one help me please
Hi - I've been having a heck of a time getting this to work. I've followed these instructions step by step, but I can't seem to get this to work. When I call $this->Facebook->share() in home.ctp, it just tells me: Undefined property: View::$Facebook [APP/views/pages/home.ctp, line 3]. I'm obviously missing something simple, but I can't seem to figure it out! Please help!
When I click "Login with Facebook", with a valid Facebook account but not a valid account on my website (which is developed in CakePHP), I am logged into facebook, which is fine, BUT my session remains on my website and subsequently the logout button is displayed, which is misleading to the user, even though I have trapped the "error" and have displayed a customised message to the user to say they do not exist on my website. Can someone help? Thanks!
danieln, I think I know what happened with your first problem. You need to set the facebook_id in your db to bigint otherwise it will overflow and always be the max value of int. I don't know the answer to your second question though.
Hi,
Can you share a bit with me, I am facing a few problems here
1) I have the registration box on my login page, the problem is whenever a person clicks on the register, it creates a new line the users table. how to avoid this?
2) I have the login button on the same login page, but when I click on it, nothing happens.
Hope you can help me on this
After some research, I found he solution to my above mentioned issue. I just changed the following:
Configure::write('Security.level', 'low');
Credit goes to the post here:
http://groups.google.com/group/cake-php/browse_thread/thread/4d7807465be56b03?pli=1
Thank you for the wonderful plugin. I tested it out and everything worked great on my public url. But when I try to use the facebook link (apps.facebook.com/myapp, it always displays the login page. What could I have done wrong here?
Hi,
can someone share the codes you've used to successfully integrate FB into cakephp?
I'm not sure where mine go wrong, I really need a sample to compare it with.
Hi Nick, I have seen similar posts in multiple locations, but have never seen an answer yet. All that is working for me is "share" anything else that requires init() is not working. I have all the applicable things needed, API Key, etc... and have the FB html and init calls placed in the right spots... Still nothing. I even did a fresh install of cake thinking I might have had some conflicts and still nothing, only share is working. I tried the migrated tip below and that doesn't work. I love the idea of this plugin and from your example page I can see they work, however a couple days ago they didn't when I checked and I noticed you made some recent updates on Github thinking whatever you did fixed things, but still nothing. So, any ideas because I would LOVE to get this plugins full functionality working for my site.
Hi Nick,
Is there a way to redirect the user after Auth? Also - does it matter that the API Key is no longer told to us in Facebook? Just APP Id and Secret?
Regards,
Barry
Hi again Nick and to all the other people looking also for the solution to the "comments" problem ( see my comment before) I found the solution.
Facebook made obsolete the old facebook comments function, the new way to call it is :
- echo $facebook->comments(array('migrated'=> '1'));
Cheers
Murciano
Hi Nick, Before Anything Thanks for your great plugin! I am trying to make comments works on my web site but I saw that you have also the same error than me into your demo web site :
- Bad parameter : "There was an error understanding the request."
Do you know how we can fix this ?
i have tested echo $this->Facebook->share(); to know if the plugin was working,this worked without errors.i tried using echo $facebook->comments(); but the comment area is not showing.
I have included echo $this->Facebook->html() and $this->Facebook->init(); in the default layout. Its not displaying any error,neither is displaying the facebook comment.
I then changed the facebook plugin parameters to a wrong one. The echo $this->Facebook->share() still worked.what could be wrong.
/**
* Get an api_key and secret from facebook and fill in this content.
* save the file to app/config/facebook.php
*/
$config = array(
'Facebookx' => array(
'appId' => '',
'apiKey' => '',
'secret' => '',
'cookie' => true,
'locale' => 'en_US',
)
);
?>
what could be wrong
hey, great tutorial and an awesome plugin; however I seem to be running into some problems with it; it appears that the Facebook Connect component causes a redirection loop when using the Login button. Please advise
65 Comments