GithubHelp home page GithubHelp logo

cakephp-facebook-plugin's Introduction

Facebook Plugin

The purpose of the Facebook plugin is to provide a seamless way to connect your cakePHP app to everyone's favorite social networking site -- Facebook. The goal for this plugin is to not only provide extremely useful dynamic features but to also provide a complete interface to the Facebook API.

Changelog

  • 1.0 Initial release alpha
  • 1.1 Added API feature
  • 1.2 Initial release beta
  • 1.2.1 Minor Bug fixes and tests
  • 1.3 Added FacebookInfo class for easy reference to plugin details anywhere.
  • 1.4.0 Added FacebookApi library. Useful for access to FacebookApi from anywhere.
  • 1.5.0 Added facebook Permissions prompts
  • 1.5.1 Facebook Connect can accept settings like all the core components in cake 1.3
  • 1.5.2 Added Facebook.Connect user method to retrieve user data much like Auth.
  • 1.5.3 Added Facebook status() function to helper.
  • 1.5.4: Fixed a bug in Facebook.Connect that would white screen if session was in an unstable state coming in.
  • 1.5.5: Bug fix for helper use only with init. Was dependant on Connect Component, but not anymore
  • 1.6: Facebook.Connect will now update a user table if it exists but a facebook_id is not found.
  • 1.6.1: Facebook::share will now property set the beginning url if no url is passed in
  • 1.7.0: Updated to the latest version of the official Facebook PHP SDK and made everything more future-proof (Theaxiom / https://www.kinspir.com)
  • 1.7.1: Fixed broken tests from update 1.7.0
  • 2.0.0: Feature updates:
    • FacebookHelper::loader() is no longer needed and is now deprecated
    • Users now created if auth is detected and no user is present with logged in facebook_id
    • FacebookHelper::logout redirect option now allows array based cakephp urls
    • New Features:
      • FacebookHelper::like() creates like button with various options
      • FacebookHelper::activity() created activity feed with various options
      • FacebookHelper::friendpile() created friendpile widget with various options
      • FacebookHelper::recommendations() create recommendations widget with various options
  • 2.0.1: New Setting ConnectComponent::createUser boolean. If set to true (default) upon a successful facebook login, and the facebook_id is not found in the User table, the component will attempt to create a new user from introspection on the Auth component. Turn this feature off by passing in 'createUser' => false when setting up the Connect component.
  • 2.0.2: New helper method getConfig() available within the FacebookInfo library. Use this to pull in facebook configurations instead of trying to rely on loaded configuration files from other sources.
  • 2.0.3: Updated Facebook::share to allow fbxml option instead of defaulting to not use fbxml. fbxml => true is required if the page loads facebook->init();
  • 2.1.0: Improved preformance and new Facebook::disconnect function.
  • 2.1.1: various minor bug fixes.
  • 2.2.0: Updated Facebook PHP SDK
  • 2.3.0: Added new Facebook::likebox to replace Facebook::fanbox()
  • 2.3.1: Security Update: facebook user creation now generates random passwords.
  • 2.4.0: Adding three Authentication callbacks: beforeFacebookSave, beforeFacebookLogin, and afterFacebookLogin
  • 2.4.1: Adding custom locale to plugin.
  • 2.4.2: minor bug fixes.
  • 2.4.3: Fixed duplicate user entry when User primaryKey is not 'id'.
  • 2.5.0: Optimizations and minor fixes (special thanks to https://github.com/bar)
    • New callback feature for FacebookHelper::init() (page refresh is still default).
    • Nicer FacebookHelper::share() now uses Router instead of environment and $this->here
    • Optimization, Moving __syncFacebookUser to after Controller->beforeFilter() so $noAuth can be changed in the beforeFilter if need be.
  • 3.0.0: Upgraded to Facebook PHP SDK v 3.1.1
  • 3.0.1: Added CakePHP 2.0 support
    • the AuthComponent in 2.0 has been redesigned significantly, making the guesswork done by the FacebookPlugin much harder to acheive

    • As such, you now have to set the model in which you want the Facebook plugin to interact with if you want User/Auth integration via database

    • You must set this when defining the Facebook.Connect component

    • If you do not set a 'model' key, integration with your Auth Model will not happen automatically.

        //Example AppController setup
        public $components = array('Session',
        	'Auth' => array(
        		'authenticate' => array(
        			'Form' => array(
        				'fields' => array('username' => 'email')
        			)
        		),
        		'authorize' => 'Controller'
        	),
        	'Facebook.Connect' => array('model' => 'User')
        );
      
  • 3.1.0: Added new facebook social features (registration and send)
    • FacebookHelper::registration() creates a registration form prepopulated with their facebook information.
    • ConnectComponent::registrationData() a useful shortcut to parsing a successful registration post to facebook.
    • FacebookHelper::sendbutton() creates a nice send button.
  • 3.1.1: Updated Facebook PHP SDK to latest release.
  • 3.1.2: Updated Facebook PHP SDK to latest release v3.2.1.
  • 3.1.3: Updated Facebook PHP SDK to latest release v3.2.3.

About Plugin

Feature List

  • Full featured authentication via facebook. Facebook Authentication will work with or without a user login system in place. Works seemlessly with your already built user authentication via AuthComponent - OR - it can work as your primary authentication system.
  • Create dynamic customizable facebook content with extreme ease.
    • Share (let your users share what they find on your site)
    • Like (let your users like what they find on your site)
    • Send (let your users send what they find on your site)
    • Login/Logout (facebook users can login and logout with a single click .. no registration required)
    • Registration (facebook users can register on your application with pre-populated data from their profile)
    • Activity (allow users to show your applications and friends activity)
    • Friend Pile (display your applications friends)
    • Recommendations (display recommended urls based on the current page)
    • Fan Boxes (allow users to become a fan of your application)
    • Profile Pictures (display a logged in user's profile picture)
    • Live Streams (create dynamic live stream events through facebook and give access through your site)
    • Comments (connect with your uses by allowing them to comment on any part of your site with facebook comments)
    • Status (display a user's status)
  • Access to Full Facebook API anywhere in your app. Built custom content directly from the Facebook API with the built in access to the full Facebook API

Install and Setup

  • First clone the repository into your app/Plugin/Facebook directory

      git clone git://github.com/webtechnick/CakePHP-Facebook-Plugin.git app/Plugin/Facebook
    
  • Load the plugin in your app/Config/bootstrap.php file:

      //app/Config/bootstrap.php
      CakePlugin::load('Facebook');
    

Once installed, if you wish to use any other features other than the share button you'll need to get an api_key and secret for your application.

  • Create an app from facebook at this url: http://www.facebook.com/developers/createapp.php

  • Once you generate an api_key and secret you'll need to create a file app/Config/facebook.php You can find an example of what you'll need and how it is laid out in /Facebook/Config/facebook.php.example

      //app/Config/facebook.php
      $config = array(
      	'Facebook' => array(
      		'appId'  => 'YOUR_APP_ID',
      		'apiKey' => 'YOUR_API_KEY',
      		'secret' => 'YOUR_SECRET',
      		'cookie' => true,
      		'locale' => 'en_US',
      	)
      );
    

Usage

You can use all or some of the Facebook plugin as you see fit. At the very least you will probably want to use the Facebook Helper

public $helpers = array('Facebook.Facebook');

If all you want to use is the share feature of the Facebook plugin you're all done.

$this->Facebook->share('http://www.example.com/url_to_share'); //(default is the current page).

Nothing else is required for the Facebook share feature. Hoever, to use the more advanced features you'll need to prepare your page a little to handle the fbxml tags.

Edit your Layout to take advantage of advanced facebook features

  1. In your layout it's highly suggest you replace your <html> tag with <?php echo $this->Facebook->html(); ?> This is required for some of the facebook features to work in IE.
  2. At the bottom of the page include <?php echo $this->Facebook->init(); ?> To load the facebook javascript api to scan your page for fbxml and replace them with various dynamic content.

Example layout

<?php echo $this->Facebook->html(); ?>
	<head>
		<title><?php echo $title_for_layout ?></title>
	</head>
	<body>
		<?php echo $content_for_layout; ?>
	</body>
	<?php echo $this->Facebook->init(); ?>
</html>

Authentication (Facebook Connect/Graph System):

Despite the name, the Facebook Connect component takes immediate advantage of the new powerful Facebook Graph API http://developers.facebook.com/docs/api

To use this feature you will first need to update your facebook application with the connect url of your application's url. This is done on the facebook application settings. http://www.facebook.com/developers/apps.php Now all you need to do is add the Facebook.Connect component to your app_controller.

public $components = array('Facebook.Connect');

That's it. You're now ready to accept facebook authentication.

Login/Logout buttons

Creates a login button: Facebook->login() ?>

Create a login button that asks for extended permissions (http://developers.facebook.com/docs/authentication/permissions)

<?php echo $this->Facebook->login(array('perms' => 'email,publish_stream')); ?>

Create a logout button:

<?php echo $this->Facebook->logout() ?>

Each button has multiple options, review the API to see all available options http://docs.webtechnick.com/facebook/classes/FacebookHelper.html

Registration Form

Create a registration form with default fields and width. Default is posting to self.

<?php echo $this->Facebook->registration(); ?>

Create a custom registration form.

<?php echo $this->Facebook->registration(array(
	'fields' => 'name,gender,location,email',
	'width' => 600,
	'redirect-uri' => 'http://www.example.com/process_facebook_registration'
)); ?>

Processing Registration Data.

To access the registartion data posted by your registration user, use the convienient ConnectComponent::registrationData() function.

if($user = $this->Connect->registrationData()){
	print_r($user);
}

Use the data in $user to finish the registration process on your own (save a new user, find/update the user, etc..)

CakePHP Auth + Facebook.Connect

Facebook.Connect will play nice with a variety of Authentication systems. It has nearly seamless integration with CakePHP AuthComponent.

note Since the CakePHP 2.0 AuthComponent revamp, ConnectComponent doesn't have the introspection available anymore. It is necessary to tell Connect what model you store your users data in for the automagic to work like so:

//Example AppController.php components settup with FacebookConnect
public $components = array('Session',
			'Auth' => array(
				'authenticate' => array(
					'Form' => array(
						'fields' => array('username' => 'email')
					)
				),
				'authorize' => 'Controller'
			),
			'Facebook.Connect' => array('model' => 'User')
		);

To integrate with CakePHP Auth, you'll need to alter your users table (or whatever table your Auth component uses) and add a new field -> facebook_id.

ALTER TABLE `users` ADD `facebook_id` BIGINT(20) UNSIGNED NOT NULL

Since you already have an authentication system, the logout step will need to also log out the user from your authentication system. You do this by passing a redirect to $facebook->logout() to your system's logout authentication action.

In this case you should set the label or img option if you want the logout button to be displayed.

<?php echo $this->Facebook->logout(array('label' => 'Logout', 'redirect' => array('controller' => 'users', 'action' => 'logout'))); ?>

or

<?php echo $this->Facebook->logout(array('redirect' => array('controller' => 'users', 'action' => 'logout'), 'img' => '/Facebook/img/facebook-logout.png')); ?>

This will log out of the facebook authentication and then redirect to your authentication logout for you to finish the logout.

Facebook Auth Callbacks

There are three callbacks available to use, each are defined in the controller and are optional to use.

  • beforeFacebookSave handle the user to save into the users table. If returned false, creation is haulted.

      //Add an email field to be saved along with creation.
      function beforeFacebookSave(){
      	$this->Connect->authUser['User']['email'] = $this->Connect->user('email');
      	return true; //Must return true or will not save.
      }
    
  • beforeFacebookLogin Handle the user before logging the user into Auth.

      function beforeFacebookLogin($user){
      	//Logic to happen before a facebook login
      }
    
  • afterFacebookLogin Handle any needed functionality right after a successful Auth Login

      function afterFacebookLogin(){
      	//Logic to happen after successful facebook login.
      	$this->redirect('/custom_facebook_redirect');
      }
    

Advanced Helper Feature Examples

<?php echo $this->Facebook->comments(); ?>
<?php echo $this->Facebook->picture($facebook_id); ?>
<?php echo $this->Facebook->recommendations(); ?>
<?php echo $this->Facebook->like(); ?>
<?php echo $this->Facebook->livestream(); ?>
<?php echo $this->Facebook->activity(); ?>
<?php echo $this->Facebook->friendpile(); ?>

Facebook API

You can access the Facebook Api from anywhere in your app. You'll need to include the Api first

App::uses('FB', 'Facebook.Lib');

Then you can instanciate it or, if you're running PHP 5.3.x you can make static calls on it.

PHP version 5.2.x

	$Facebook = new FB();
	$Facebook->api('/me');

PHP 5.3.x

	FB::api('/me');

Internationalization

You can set the locale of the plugin through the helper declaration or through the config/facebook.php configuration file (see top of document).

public $helpers = array('Facebook.Facebook' => array('locale' => 'en_US'));

Facebook locales: http://developers.facebook.com/docs/internationalization/

Read the Docs

I encourage you to read the documentation and API for this plugin to see all the features and options for each feature. The API is here: http://docs.webtechnick.com/facebook/

cakephp-facebook-plugin's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cakephp-facebook-plugin's Issues

Custom Login Permissions

Firstly this is a great plugin that saved me loads of time, thank you!

The login control is ignoring permissions when custom is set to true because the 'scope' option is hard coded to 'email' in the javascript login function.

I fixed this by passing through the perms string to the login function, for reference here are my changes to the FacebookHelper class:
113 - $perms = isset($options['perms']) ? $options['perms'] : 'email';
$onclick = "login('".$options['redirect']."', '".$perms."');";

497 - function login(redirection, perms){

510 - }, {scope: perms});

Nothing displayed

Hi Nick,

After following the instructions from the Readme file I wanted to display a comment box. However; nothing is displayed, no comment box and no errors.

I have uploaded all files to the facebook directory within plugins, changed the settings in the config file, loaded the helper (the tag is correctly changed, as well as the javascript that's added to the bottom of my page), but nothing happens.

Any ideas? Thanks in advance!

Facebook comment area not rendering

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.

array( 'appId' => '', 'apiKey' => '', 'secret' => '', 'cookie' => true, 'locale' => 'en_US', ) ); ?>

what could be wrong

Error

So I've extracted the folder in the zip, I am getting:

Undefined variable: facebook [APP/views/layouts/default.ctp, line 1]
Fatal error: Call to a member function html() on a non-object in /var/projects/dormillo/app/views/layouts/default.ctp on line 1 

Not quite sure what I'm doing wrong? I've followed the instructions in the readme including the config file...

In my AppController,

public $components = array('Session', 'RequestHandler', 'Auth', 'Facebook', 'Facebook.Connect', 'Facebook.FacebookApi');

And yep, it's cake 1.3

CakePHP 2.0 Redirect after login does not work

Method I

        $this->redirect(array('controller' => 'pages', 'action' => 'home'));
   }

My afterFacebookLogin() function it only works after I reload the page from where I logged in or go to another page.

Method II

I also tried to enable 'redirect' => true in FacebookHelper.php. The problem is that when it is set to true it dissapears.

What can I do in this case?

Login button invisible after initial login (cake 2.0 branch)

I got the following problem, I try to get Facebook Connect working. The problem:

1.) $this->Facebook->login(); creates a Login button which shows up. After I click it Facebook asks me for permission which works fine. I accept it and I am logged in.

2.) I logout of my page with $this->Facebook->logout(); I get logged out of Facebook AND my application. So far so good. But when I go to my start page on my website, the Facebook login button does not appear anymore.

It seems the JS tries to poll some information from FB since there is this loading animation but it then disappears into nothing. When I log in via facebook itself I am logged in again in my application. Maybe its a problem with the facebook API itself? But I could not find any clue :( One other detail: when I go to facebook privacy settings and delete the connection to my application/website, the login button appears again...

Testwebsite: http://shoodi.tfelix.de (website for recording shooting results, sorry its in german for now, but I think to recreate the funny behaviour its enough...)

FB Login button doesn't appear on Firefox

Just followed the tutorial exactly as you had it in the screencast.

Facebook->login(); ?> gets converted to fb:login-button but does not get turned into an actual login button in Firefox 6.0.2 at least. Doubt its a problem with your code, seems more like something to do with Firefox, but just thought I'd let you know and see if you have any ideas.

OAuth2 Incompatibility Issue

I keep getting the following error. Any ideas?

Error: FB.Auth.setSession incompatible with OAuth2.

Facebook config:

array( 'appId' => '244224708951284', 'apiKey' => '9747b40bc8bf0d6fd5ce3c7f71848136', 'secret' => 'fcf31bb815c9a6ee21101ff2e2dadfb1', 'cookie' => true, 'locale' => 'en_US' //'xfbml' => true, //'oauth' => true ) ); ?>

Facebook app settings:
Remove Deprecated Auth Methods - Enabled
Stream post URL security - Disabled
signed_request for Canvas - Enabled
Timezone-less events - Enabled
Upgrade to Requests 2.0 - Disabled
iframe Page Tab - Enabled
Require manage_notifications - Enabled
OAuth Migration - Disabled
Develop Using Deprecated FBML Canvas - Disabled

Share and comments can't be used together

Hi,

I'm writing a facebook application using this wonderful plugin, thanks!
I'm wondering though, why both comments and share function work when used separately, but stop working when used together?
If i try to use them both i only get the share button (no comments). why is that? minor bug or am i confused in smth?

thanks!

Lucas

Fatal error!!!

my problem is,if i run my apps on web project.facebookviet.vn,no problem
but when i run my apps on host sieu.vn,have one error:

Fatal error: Uncaught GraphMethodException: Unsupported get request. thrown in mydomain\wwwroot\apps\base_facebook.php on line 1033
and in fbmain.php have one a error:
Fatal error: Class 'Facebook' not found in D:\Domains\sieu.vn\wwwroot\apps\fbmain.php on line 26
i don't know,please help me
thank all!

Custom Login Image Path

Thank you again for this awesome plugin.

The image path in the FacebookHelper for the custom login button gets changed to:

$source = '/Facebook/img/'.$options['img'];

It would be nice to have the flexibility of passing through the path you would like to use.

Database table error with cake 2.0

Hi there,
I get the following when trying to initialize the plugin. The actual button for login works, but the page is filled with an error when the plugin is active:
Missing Database Table
Error: Database table app_models for model AppModel was not found.
Notice: If you want to customize this error message, create app/View/Errors/missing_table.ctp
Stack Trace
#0 /Users/jwilcox/Projects/web-applications/akzo-color/lib/Cake/Model/Model.php(3236): Model->setSource('app_models')
#1 /Users/jwilcox/Projects/web-applications/akzo-color/lib/Cake/Model/Model.php(1206): Model->getDataSource()
#2 /Users/jwilcox/Projects/web-applications/akzo-color/lib/Cake/Model/Model.php(1292): Model->schema()
#3 /Users/jwilcox/Projects/web-applications/akzo-color/app/Plugin/Facebook/Controller/Component/ConnectComponent.php(108): Model->hasField('facebook_id')
#4 /Users/jwilcox/Projects/web-applications/akzo-color/app/Plugin/Facebook/Controller/Component/ConnectComponent.php(80): ConnectComponent->__syncFacebookUser()
#5 [internal function]: ConnectComponent->startup(Object(PagesController))
#6 /Users/jwilcox/Projects/web-applications/akzo-color/lib/Cake/Utility/ObjectCollection.php(110): call_user_func_array(Array, Array)
#7 /Users/jwilcox/Projects/web-applications/akzo-color/lib/Cake/Controller/Controller.php(606): ObjectCollection->trigger('startup', Array)
#8 /Users/jwilcox/Projects/web-applications/akzo-color/lib/Cake/Routing/Dispatcher.php(104): Controller->startupProcess()
#9 /Users/jwilcox/Projects/web-applications/akzo-color/lib/Cake/Routing/Dispatcher.php(89): Dispatcher->_invoke(Object(PagesController), Object(CakeRequest), Object(CakeResponse))
#10 /Users/jwilcox/Projects/web-applications/akzo-color/app/webroot/index.php(96): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#11 {main}

I wasnt sure if I had to create a new table for some reason, but I couldn't figure out the problem. I am using Cake 2.0 and trying to hook into the Auth I already have. Thanks for any support!

Cakephp 2.0 - afterFacebookLogin doens't works

Hello,
I write my afterFacebookLogin() function in the Users controller where I put in the login action the fb login.

After login the function doesn't work!

Kind regards,
Alex Genovese

Logout not working

I use this, but dont work:

Facebook->logout( array('redirect' => array('controller' => 'users', 'action' => 'logout', 'panel' => true) )); ?>

Using cakephp 1.3
Login function working perfectly.

Thanks.

Class 'Facebook' not found

Hi,

i'm trying to use the plugin but i can't bring it on work. I get following:

Fatal error: Class 'Facebook' not found in /Users/eneskul/Desktop/vhosts/game/htdocs/app/Plugin/Facebook/libs/f_b.php on line 22

My AppController:

public $components = array('Session',
    'Auth' => array(
        'authenticate' => array(
            'Form' => array(
                'fields' => array('username' => 'email')
            )
        ),
        'authorize' => 'Controller'
    ),
    'Facebook.Connect' => array('model' => 'User')
);


function beforeFilter()
{
    //Configure AuthComponent

    $this->Auth->allow('*');
    $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
    $this->Auth->logoutRedirect = array('controller' => 'users', 'action' => 'login');
    $this->Auth->loginRedirect = array('controller' => 'users', 'action' => 'index');
}

CakePHP version 2.0.3

It seems that "perms" is not valid anymore

Hi! Four days ago everything was working well on my site (localhost), I'm using CakePHP-Facebook-Plugin in order to authenticate users into my site through facebook, but then not anymore. I blamed on some changed I did and I rolled back to the "latest-working" versions from the SVN and it seems I still get the same problem.

I tracked down a JS exception and it seems the problem is the "perms" parameter on login() function. Then I changed "perms" to "scope" and the facebook popup is working again but with some other problems, anyway this is the code

$facebook->login(array('perms' => 'email')); // not working
$facebook->login(array('scope' => 'email')); // working

am I the only one that is getting this problem?
Thanks

This is the JS error:
OAuth2 specification states that 'perms' should now be called 'scope'. Please update.
[Break On This Error] FB.provide('',{getLoginStatus:function...signed_request,code'});return a;}}});

Fatal error: Facebook not found in /Plugin/Facebook/libs/f_b.php

Hello,
I have installed in /app/plugin/ the Facebook Plugin in Cakephp 2.0.5 but it doesn't work fine.

Steps:

  1. copied the plugin in in app/plugin/
  2. facebook.php copied in app/config/ configuration files with all configuration codes.
  3. replaced the layout with that in the example

the error is:

Fatal error: Class 'Facebook' not found in /Applications/MAMP/htdocs/emailmarketing/app/Plugin/Facebook/libs/f_b.php on line 21

Thanks in advance
Alex Genovese

Call to undefined method SessionComponent::start() connect.php on line 64

i created app which has user authentication all ready, i want to implement facebook plugin but after entering

var $components = array('Auth', 'Session','Facebook.Connect');
var $helpers = array('Html', 'Form', 'Js', 'Session', 'Facebook.Facebook');

i get an error

Fatal error: Call to undefined method SessionComponent::start() in /Users/emrahgul/Sites/evento2/app/Plugin/Facebook/controllers/components/connect.php on line 64

can some one help

Infinite reload

Hey Nick, thanks for your plugin.
In the lasts months, something goes wrong, I have this problem:
If I am logged in facebook and I go on the website that I'm working on, there is an reload every second.

I've seen that you have the same problem in the application example.
http://facebook.webtechnick.com/
I'm triyng to figure out whats happen, It's seems that at the connect.php line 61 the getSession() method fail.

Have you some suggestion about?

Facebooks users information only show after second acess

I'm using cakephp 2.0

step to procedure :

        $this->Connect->authUser['User']['name'] = $this->Connect->user('name');
        return true; //Must return true or will not save.

`````` }

Erase cookies and the user in the table ...
Try to acess your application , the name in table will be null.
Refresh  the page and the name will be update.

I fix it puting this lines in Initialize (and remove startup method)
```if (!$this->noAuth && !empty($this->uid)) {
    $this->__syncFacebookUser();
```}

Login/Logout buttons

Hi, i added the follow code to my home.ctp page but the login/out button don't work properly.

Facebook->logout(); ?> Facebook->login(); ?>

it seems like the redirect don't work at all, what im doing wrong?

FB::api('/me') doesn't work ?

Hi i'm getting php warning when trying to access to the facebook api :

Warning (2): call_user_func_array() expects parameter 1 to be a valid callback, first array member is not a valid class name or object [APP/Plugin/facebook/Lib/FB.php, line 58]

and the FB::api('/me') call doesn't show any result ?
Any help well be great !!!! Thanks

Class 'Facebook' not found

Hi,

i'm trying to use the plugin but i can't bring it on work. I get following:

Fatal error: Class 'Facebook' not found in /Users/emrahgul/Sites/evento/app/Plugin/Facebook/libs/f_b.php on line 21

public function __construct() {
if (empty(self::$Facebook)) {
self::$Facebook = new Facebook(FacebookInfo::getConfig());
}
}

CAKEPHP FACEBOOK PLUGIN version 3.1.1

Canvas page constantly refreshes

I'm getting reports that some people are constantly getting page reloads when they visit my app. Looking through forums and everything I'm thinking it may have something to do with the user not being able to get authenticated correctly thus causing this line to be run:

FB.Event.subscribe('auth.login',function(){window.location.reload()});

I was also just now able to reproduce this refreshing on Safari and IE7

Login Button does not appear at firefox

Dear Nick, I have play around with the branch 2.0 with the Facebook->login();?> but the Login Button seem like does not work. So, I remove the FacebookHelper.php Line 458: $init .= '<script src="//connect.facebook.net/en_US/all.js"></script>'; and the button appear. That's my report. Thanks

FB Helper init function

In the FB.init() there is the status flag, you could put it in the configuration, because this causes some errors when you are logged in as a normal user (nof from facebook connect) and do not want to connect your accont with the facebook account.

unidefined property:Facebook

I have trying the fix this error.i seem not to know its source. Notice (8): Undefined property: View::$Facebook [APP\views\pages\display.ctp, line 3].

please help

Class 'FB' not found

hi,

i am using 2.1.1 facebook plugin in cakephp but it is not working.
every time show "Fatal error: Class 'FB' not found in /app/controllers/components/connect.php on line 61 "
this error.

please help

roseroja

Unable to log out issue

So I've got the system working half-well. When I log into facebook, it logs me into my cakePHP app.

In my users/logout function, I redirect back to the homepage.

I've routed the facebook logout to my logout function in my users controller. When I use that, the logout logs me out of facebook but not on my cakePHP app.

When I log out by going just to the logout function while still logged into facebook (and not logging out of facebook), nothing happens.

I removed the redirect from the logout function and when I sign out, it appears to work, but when I navigate back to the home page (or any other page), it logs me back into my cakePHP app.

My solution for this was to manually delete the entire session before I redirect

function logout()
{
$this->Auth->logout();
$this->Session->destroy();
$this->redirect(array('controller' => 'articles', 'action' => 'index'));
}

While this appears to be working, I'd like to know why it's necessary? What am I doing wrong here??

FB login screen doesn't disappear after login

Hi Nick,

Thank you for this awesome plugin. I have it working except for the login functionality.

I am using 2.0 and Auth with Security.

For some reason when I use the FB login and fill out my FB info in the FB window and hit submit the window does not disappear and I have to hit my login button on my app two times to get the system to recognize me.

This is after I close the initial FB screen which has turned white and still appears over my browser.

I thought I could add a redirect in the actual FB login Facebook->login(array('perms' => 'email, user_birthday')); ?> but when i try to do that it breaks the code and doesn't show up.

Facebook->login(array('perms' => 'email, user_birthday', 'show_faces' => false, 'width' => 400, 'redirect' => '/users/login/')); ?>

gives me

Thanks again. Any help is appreciated.

Brad

Facebook::__construct() call session_start() before CakeSession

Seem that Facebook SDK class breaks cakephp session behavior starting session outside of session component, because of CakePHP1.3 (2.0+ too?) starts session in SessionComponent::startup() after Components::initialize and Controller::beforeFilter() in Controller::startupProcess.

So, database and cake sessions dont work.

I temporary solved with a workaround patching ConnectComponent::initialize() to force Session start before of Facebook::__construct().

    function initialize(&$Controller, $settings = array()){
        $this->Controller = $Controller;
        if (!$this->Controller->Session->started()) {
            $this->Controller->Session->start();
        }
        $this->_set($settings);
        $this->FB = new FB();
        $this->uid = $this->FB->getUser();
    }

I cant'n use the plugin

Hi, i have cake 2.0.2 and i trying to use the plugin, i follow all the instruccions but always say : "Fatal error: Call to a member function info() on a non-object in C:\servidor\astroagenda\app\View\Pages\home.ctp on line 3 "

function html() on a non-object

i download the file in https://github.com/webtechnick/CakePHP-Facebook-Plugin/tree/cakephp2.0
and followed the instructions but i seem to get an error when i add "Facebook.Connect" in AppController.php
here is the AppController code

class AppController extends Controller {

var $uses = array('Messages.Message', 'Settings', 'User');
var $components = array('Auth', 'Session', 'Facebook.Connect' );
var $helpers = array('Html', 'Form', 'Js', 'Session', 'Facebook.Facebook');

and the code for default.ctp is

Facebook->html(); ?> <title></title> <
Facebook->share(); ?>
<div id="header">
element('sql_dump'); ?> Facebook->init(); ?>

Fatal error: Call to a member function html() on a non-object in app/View/Layouts/default.ctp on line 2

Cannot connect with database

I am using CakePHP 2.0.5 / OS X 10.6 / MAMP PRO

I can't get it working with the cakephp auth. I followed the video tutorial and I've read the installation tutorial but it does not change anything in the database. When I login with facebook it doesn't execute any query at all. Also it does not show the logout button.

You can see what it displays after login here: http://i43.tinypic.com/144cw94.jpg

What could cause this problems?
If there is anything more that you need to help me please ask.

Thank you in advance.

Here you have come code:

AppController.php

class AppController extends Controller {
    public $helpers = array('Facebook.Facebook', 'Html', 'Session', 'Form');

    public $components = array(
        'Session',
        'Auth' => array(
            'loginRedirect' => array('admin' => 'false', 'controller' => 'users', 'action' => 'index'),
            'logoutRedirect' => array('controller' => 'users', 'action' => 'index'),
            'authorize' => array('Controller'),
        ),
        'Facebook.Connect'
    );

    function beforeFilter() {
        $this->Auth->allow('display'); //obligatorie
        $this->set('facebook_user', $this->Connect->user());
        $this->set('logged_in', $this->_loggedIn());
        $this->set('currentUser', $this->Auth->user());
        if (isset($this->params['admin']) && $this->params['admin'] == 'admin') {
                    $this->layout = 'admin';
        }
    }

    function beforeFacebookSave(){
        $this->Connect->authUser['User']['email'] = $this->Connect->user('email');
        return true; //Must return true or will not save.
    }

    public function isAuthorized() {
        return true;
    }

    public function _loggedIn(){
            $logged_in=FALSE;
            if ($this->Auth->user()){
                $logged_in=TRUE;
            }
            return $logged_in;
            //!empty($this->Auth->user());
    }
}

In the view i've put the following code:

`````` $this->Facebook->login()```

I have also replaced <html> with the next line:
echo $this->Facebook->html();

and i've put this line just before </body>
echo $this->Facebook->init();

In the database inside table users i've added a column named facebook_id

security concern

are you sure setting a default password value is a good idea ? https://github.com/webtechnick/CakePHP-Facebook-Plugin/blob/master/controllers/components/connect.php#L108

Let study the following case :

  • i log-in with facebook. my account password has now the "disabled" value (actually it is not disabled, just having this value)
  • sometimes on the web site, i can change/add my email address
  • this website has kept the CakePHP Auth login system enabled (because not everyone wants to log with facebook)
  • someone (for instance a facebook "friend") knows my email address and that i logged on the website
  • he just have to go to the website and enters my email address as the login and "disabled" as the password
  • he got my identity on the website

I haven't tested it now, i'll keep you in touch when this is done.

FB oAuth 2.0 update breaks plugin

With today's Facebook update all apps that are using this plugins Facebook Login is broken, including the demo on facebook.webtechnick.com.

This needs to be fixed as it cripples many sites.

login logout issue

Hi,

I just realized your website doesn't work properly. I'm not able to login to see "myaccount", i always see the login button. The first time i got the permissions request, but after that i still can't see "myaccount".

I have a similar problem in my application. I followed your screencast and the svn app. I can log in, i. e., when i login via facebook, i can see "myaccount". The problem is, when i click logout, i only exit the facebook session, but i can still see myaccount... any help?

Maybe the my app's advanced configs have somthing to do...

Running Mac OS X Lion
with Chrome 13.0.782.99 beta
from Facebook iFrame Canvas @ php sdk 3.1.1

CakePHP 2.0 and the Facebook Plugin

I can't seem to get this to work with cakephp 2.0. Is there something in the plugin that needs to change, or is there any timeline for when it might work? I followed your steps to a T and it was working fine in 1.3, but I have a new site that is written with 2.0 that needs this. Thanks!

1.3 Current FB SDK needs to be upgraded.

The current version (included in your plugin) incorrectly handles FB session cookies which are used for login. The latest version of the FB PHP SDK appears to work fine.

Login fails on primary key

I have the facebook_id as a primary key for my auth table. I want to duplicate the facebook graph for the users I get, but when it goes to login, if the facebook_id already exists it doesn't update the password field, and instead fails to update the view UI instead.

Not sure if this is in the Auth component of CakePHP or in the Facebook code. Happy to help fix it however I can.

Make extending "User" object easier

It would be nice if it were easier to extend the "User" object so that more than the Facebook ID can be saved as part of the Auth registration flow

Changing button style

I would to use a different FB Connect button than the default one, how can I change the style of it?

First page load fails to login on Canvas App

First of all, thanks for the great plugin! It helped me a LOT!

Now for the issue:

When making a canvas app, you don't really need to check if the user is logged in to Facebook, since the user isn't supposed to get to the page if he isnt. The canvas app works from inside facebook itself, so that's why.

Problem is when I open the first page on the canvas app, both Auth and Connect->user() are empty, meaning there's no user logged in (which isn't true, of course). When I refresh the frame or click on any page inside it, then it's all normal, both Auth and Connect->user() show the correct info.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.