webtechnick / CakePHP-Facebook-Plugin

CakePHP Facebook Plugin
http://facebook.webtechnick.com
445 stars 138 forks source link

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] #119

Open godara opened 11 years ago

godara commented 11 years ago

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?

starchildno1 commented 11 years ago

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()

godara commented 11 years ago

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

godara commented 11 years ago

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

)

starchildno1 commented 11 years ago

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.