简体   繁体   English

找不到Codeigniter中的Facebook登录Facebook \\ Facebook类

[英]Facebook Login in Codeigniter Facebook\Facebook class not found

I m trying to integtrate Facebook login in my website. 我正在尝试在我的网站中整合Facebook登录。 I downloaded and integrated all library files in my web App directory. 我将所有库文件下载并集成到了Web App目录中。 But i get an error. 但是我得到一个错误。

An uncaught Exception was encountered Type: Error 遇到未捕获的异常类型:错误

Message: Class 'Facebook\\Facebook' not found 消息:找不到类“ Facebook \\ Facebook”

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

Line Number: 68 行号:68

Backtrace: 回溯:

File: C:\\xampp\\htdocs\\fyp\\application\\controllers\\User_authentication.php Line: 8 Function: library 文件:C:\\ xampp \\ htdocs \\ fyp \\ application \\ controllers \\ User_authentication.php行:8功能:库

File: C:\\xampp\\htdocs\\fyp\\index.php Line: 315 Function: require_once 文件:C:\\ xampp \\ htdocs \\ fyp \\ index.php行:315功能:require_once

C:\\xampp\\htdocs\\fyp\\application\\libraries\\Facebook.php here is code of Line No 68 C:\\ xampp \\ htdocs \\ fyp \\ application \\ libraries \\ Facebook.php这是第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. 在文件顶部,您还不需要Facebook API。

Try to move require_onde to the top also 尝试将require_onde也移到顶部

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): 最新版本的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 在stderr中发送的FastCGI:“ PHP消息:PHP致命错误:在” /var/www/connect/lib/vendor/hybridauth/hybridauth/hybridauth/Hybrid/Providers/Facebook.php”中找不到类'Facebook \\ Facebook'从上游读取响应标头时为56英寸

I installed HybridAuth via composer, so I also get the new facebook sdk. 我通过composer安装了HybridAuth,因此我也得到了新的facebook sdk。 Is the new facebook sdk (5.4.1) stable? 新的Facebook SDK(5.4.1)是否稳定? 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. 我使用旧版SDK降级了HybridAuth 2.7版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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