Question:

I have been following sample codes that I found in the Internet written based on the PHP SDK. However, I am getting error "Call to undefined method Facebook::getSession()" when I run the script. What is wrong?

 

 

Answer:

Appreciate if you can like this page if you find it useful! - Click "Like"

The getSession() exists in the PHP SDK v2.x but it was removed since the PHP SDK v3.0.

We should now call the getUser() method. it wil return, if available, a "user" object instead of the previously returned session object.

For details of this change, you can referred to my tutorials on Upgrading to the PHP SDK v3.0 here.

 

Find my FAQ on Facebook Development useful? Download the PDF for all the FAQs HERE!