CakePHP-Facebook-Plugin icon indicating copy to clipboard operation
CakePHP-Facebook-Plugin copied to clipboard

call_user_func_array() expects parameter 1 to be a valid callback, class 'Facebook' does not have a method 'getSession' [APP\Plugin\Facebook\Lib\FB.php, line 34]

Open godara opened this issue 12 years ago • 4 comments

0 down vote favorite

i am trying to do facebook login in cakephp. I am able to login successfully but cant retrieve user info. I am using the facebook plugin from the following link:

https://github.com/webtechnick/CakePHP-Facebook-Plugin

app controller:

class AppController extends Controller {

var $helpers=array('Session','facebook.facebook');

//var $components = array('Session','facebook.Connect');

function beforeFilter() { //$this->set('facebook_user',$this->Connect->user('email')); }

when i uncomment the components line i get the following error:

call_user_func_array() expects parameter 1 to be a valid callback, class 'Facebook' does not have a method 'getSession' [APP\Plugin\Facebook\Lib\FB.php, line 34]

view.ctp

echo $this->Facebook->login();

how do i solve this?

godara avatar Feb 08 '13 13:02 godara

Check your Session for [FB] => Array ([Me]) because that's where $this->Connect->user('email') gets it's info. pr($this->Session->read());

//var $components = array('Session', 'Facebook.Connect' => array('model' => 'TheNameOfYourUserModel') ); Also the user never exsist in your database because Facebook.Connect needs to know what model to write and read users from. __initUserModel()

starchildno1 avatar Feb 08 '13 21:02 starchildno1

@starchildno1 - where do i write code to check the session and how? i mean can you suggest the code?

godara avatar Feb 09 '13 04:02 godara

well i checked pr($this->Session->read()); in AppController, it prints a blank array Array ( [FB] => Array ( [Me] => )

)

godara avatar Feb 09 '13 04:02 godara

If [FB][ME] is not empty if you go to another page or reload the page you logged in with Facebook from then read issue #51 So go into Facebook\Controllers\Component\ConnectComponent.php and copy the if statement in the startup() and paste it into the bottom of the initialize(). Remember to comment out the startup() don't delete it because the issue was never resolved.

starchildno1 avatar Feb 10 '13 02:02 starchildno1