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

grayb’s picture

I 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.

ebeyrent’s picture

I 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.

tgriswold’s picture

I 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

drnikki’s picture

Indeed. Reverting back to
https://github.com/facebook/php-sdk/blob/7ce1f326d470964ea3f492eb1ae597a... specifically worked for me.

doka’s picture

The 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,

If you’re currently using the PHP SDK (v2.2.x) for authentication, you will recall that the login code looked like this:
     $facebook = new Facebook(…);
     $session = $facebook->getSession();
     if ($session) {
       // proceed knowing you have a valid user session
     } else {
       // proceed knowing you require user login and/or authentication
     }

The login code is now:

     $facebook = new Facebook(…);
     $user = $facebook->getUser();
     if ($user) {
       // proceed knowing you have a logged in user who's authenticated
     } else {
       // proceed knowing you require user login and/or authentication
     }
skolesnyk’s picture

It's a minor change if you want it to be compatible with Facebook SDK 3.x

Change line 386 in fbconnect.module to

if ($client && $session = $client->getUser()) {
drwierdo’s picture

In the latest dev version the said change should be made in line 400

MakeOnlineShop’s picture

I also changed for v2.1.2.zip and it seems to work now !

Thanks.

kriskhaira’s picture

#6 works for me on line 440 in the latest dev version.

diggingrelic’s picture

I 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

Youssef’s picture

may 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 ;)

wxman’s picture

I was able to use 3.1.1 after trying solution in #6.

acouch’s picture

Status: Active » Closed (duplicate)

This was fixed in #1169694: Upgrade to PHP SDK ver 3.1.1 for 7.x . Marking as a duplicate.

soundboy89’s picture

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

allisonc’s picture

Issue summary: View changes

For anyone still looking for version 2.1.1, it is located here: https://github.com/facebookarchive/facebook-php-sdk/tree/v2.1.1