0

Hello I'm working with a PHP code using Facebook SDK to post a message on a facbook page which I am the admin it's ok when I work in localhost but when I hosted my page on a web server it gives me the following error:

 Fatal error: Class 'Facebook\FacebookSession' not found in /var/www/simo/index.php on line 48

The lines of code that cause problem:

use Facebook\FacebookRedirectLoginHelper;
use Facebook\FacebookSession;
use Facebook\FacebookRequest;

require "vendor/autoload.php"; 
session_start();
$appId='358738637667835';
$appSecret='92841aa4b36c9c37a4d779e801db3d6f';
FacebookSession::setDefaultApplication($appId,$appSecret);//(line 48)

The thing that should be noted is that the version of my server’s PHP is “PHP 5.4.39” that normally understands the instruction "use".

Thank you for giving me a solution or a suggestion.

  • possible duplicate of [Error: Class 'Facebook\FacebookSession' not found with the facebook PHP SDK](http://stackoverflow.com/questions/23569934/error-class-facebook-facebooksession-not-found-with-the-facebook-php-sdk) – andyrandy May 15 '15 at 11:40
  • Hi, i too faced this same kind of issue with facebook SDK, you need to require_once ' ', the classes that are using in the use statement. – Sourabh Kumar Sharma May 15 '15 at 11:43

1 Answers1

0

This problem happens as a result of incorrect paths. If you downloaded the PHP SDK , make sure it contains a file called "autoload.php", then add the following line

require __DIR__ . '/facebook-php-sdk/autoload.php';

before the "use statement"

use Facebook\FacebookRedirectLoginHelper;
use Facebook\FacebookSession;

the autoload.php will fix all paths and do the mapping for you

Mayur Buragohain
  • 1,566
  • 1
  • 22
  • 42
Doaa Magdy
  • 518
  • 5
  • 20