I followed all the steps in the readme.txt file, including the updates and suggestions provided in bug [1157680], but now I'm getting this error. It completely shuts down my site.
Fatal error: Call to undefined method Facebook::getSession() in /[path]/public_html/sites/all/modules/fbconnect/fbconnect.module on line 400
Comments
Comment #1
grayb commentedI found that this was because I was using the most recent Facebook PHP SDK, which doesn't have a Facebook:getSession() function.
You'll need to revert to an older 2.x version of the SDK, but I haven't been able to get it to work fully with that one either.
Comment #2
ebeyrent commentedI am getting this fatal error with the 6.x version of the module and the latest FB SDK. Switching back to 2.1.2 of the SDK resolved the error.
Comment #3
tgriswold commentedI am getting the same error on a virgin installation D7 with latest SDK version. went back to SDK 2.1.1 and cleared the error. visit - http://github.com/facebook/php-sdk/blob/master/src/facebook.php#L284 for old facebook library
Comment #4
drnikki commentedIndeed. Reverting back to
https://github.com/facebook/php-sdk/blob/7ce1f326d470964ea3f492eb1ae597a... specifically worked for me.
Comment #5
doka commentedThe change happened from PHP SDK (v2.2.x) to PHP SDK (v.3.0.0), check the changelog file in the SDK. So up to 2.2 it should work,
Comment #6
skolesnyk commentedIt's a minor change if you want it to be compatible with Facebook SDK 3.x
Change line 386 in fbconnect.module to
Comment #7
drwierdo commentedIn the latest dev version the said change should be made in line 400
Comment #8
MakeOnlineShop commentedI also changed for v2.1.2.zip and it seems to work now !
Thanks.
Comment #9
kriskhaira commented#6 works for me on line 440 in the latest dev version.
Comment #10
diggingrelic commentedI cannot get it to work regardless. I have same error except I get line 440.
Fatal error: Call to undefined method Facebook::getSession() in /[path]/public_html/sites/all/modules/fbconnect/fbconnect.module on line 440
It brings down the entire site, the only way to get back is to move it outside the modules directory. It is still enabled then and when you try to configure it it says "Ensure that you entered valid api keys." When the keys entered are correct.
I have tried many versions of the facebook.php library and the latest version of this module as of 9/6/11
Comment #11
Youssef commentedmay be i have correct it
1.first time iwas having this error
Fatal error: Call to a member function getSession() on a non-object in /.../sites/all/modules/fbconnect/fbconnect.module on line 440
its was blocking the whole website
its reffer to line 440 just go to it
2. this is what you have at line 440 this function
function fbconnect_get_fbuid($check_connected = FALSE) {
global $user;
$client = facebook_client();
$session = $client->getSession();
if ($client && $session != NULL) {
$fbuid = $session['uid'];
if ($check_connected && $fbuid) {
if (_get_user_fbuid($user->uid) != $fbuid) {
$fbuid = NULL;
}
}
return $fbuid;
}
else {
return 0;
}
}
just add if ($client && $session = $client->getUser()) { & close it in the end
you will have this
function fbconnect_get_fbuid($check_connected = FALSE) {
global $user;
$client = facebook_client();
if ($client && $session = $client->getUser()) {
$session = $client->getSession();
if ($client && $session != NULL) {
$fbuid = $session['uid'];
if ($check_connected && $fbuid) {
if (_get_user_fbuid($user->uid) != $fbuid) {
$fbuid = NULL;
}
}
return $fbuid;
}
else {
return 0;
}}
}
bye ;)
i wich working with your team to develop this amazing module ;)
Comment #12
wxman commentedI was able to use 3.1.1 after trying solution in #6.
Comment #13
acouch commentedThis was fixed in #1169694: Upgrade to PHP SDK ver 3.1.1 for 7.x . Marking as a duplicate.
Comment #14
soundboy89 commented#6 worked for me.
The line of code originally read
if ($client && $session = $client->getSession()) {So it's just a matter of changing getSession() for getUser().
Comment #15
allisonc commentedFor anyone still looking for version 2.1.1, it is located here: https://github.com/facebookarchive/facebook-php-sdk/tree/v2.1.1