简体   繁体   中英

Facebook Login in Codeigniter Facebook\Facebook class not found

I m trying to integtrate Facebook login in my website. I downloaded and integrated all library files in my web App directory. But i get an error.

An uncaught Exception was encountered Type: Error

Message: Class 'Facebook\\Facebook' not found

Filename: C:\\xampp\\htdocs\\fyp\\application\\libraries\\Facebook.php

Line Number: 68

Backtrace:

File: C:\\xampp\\htdocs\\fyp\\application\\controllers\\User_authentication.php Line: 8 Function: library

File: C:\\xampp\\htdocs\\fyp\\index.php Line: 315 Function: require_once

C:\\xampp\\htdocs\\fyp\\application\\libraries\\Facebook.php here is code of Line No 68

if (!isset($this->fb))
{
    require_once 'facebook-php-sdk/autoload.php';
    $this->fb = new FB([
    'app_id'=> $this->config->item('facebook_app_id'),
    'app_secret'=> $this->config->item('facebook_app_secret'),
    'default_graph_version' => $this->config->item('facebook_graph_version')
]);
}

at the top of file i added line

use Facebook\Facebook as FB;

At the top of the file you have not required Facebook API yet.

Try to move require_onde to the top also

require_once 'facebook-php-sdk/autoload.php';
use Facebook\Facebook as FB;

I get the same error with the latest version of HybridAuth (2.8):

FastCGI sent in stderr: "PHP message: PHP Fatal error: Class 'Facebook\\Facebook' not found in "/var/www/connect/lib/vendor/hybridauth/hybridauth/hybridauth/Hybrid/Providers/Facebook.php" on line 56" while reading response header from upstream

I installed HybridAuth via composer, so I also get the new facebook sdk. Is the new facebook sdk (5.4.1) stable? Or is it included correctly? Because the error seems to be a namespace's error.

I fixed with a downgrade a 2.7 version of hybridauth, with the older sdk.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM