问题描述
我正在尝试使用Facebook lib v4来创建一个简单的Facebook登录信息。
I'm trying use Facebook lib v4 to create a simple Facebook login.
我正在关注Facebook指南,我坚持认为,CakePHP不是找到FacebookSession类,请按照以下事实:
I'm following Facebook guide and I'm stucked at begnning, CakePHP is not finding FacebookSession class, follow below the facts:
FacebookSession类路径:
FacebookSession class path:
App/Lib/Facebook/src/Facebook
在控制器中使用:
app::uses('FacebookSession', 'Facebook/src/Facebook');
我认为问题是在这个特定的Facebook Lib,因为我使用WideImage类,
I think the Issue is in this specific Facebook Lib because I'm using WideImage class and I'm applying the same logic to use the Class and is working Perfectly.
对于记录,我使用PHP 5.4
For the record I'm using PHP 5.4
推荐答案
自定义路径/包需要注册
首先,不是 uses()
工程。自定义路径/程序包需要先注册,请参阅
Custom paths/packages need to be registered
First of all that's not how App::uses()
works. Custom paths/packages need to be registered first, please refer to CakePHP: unable to load class from app/Lib
还有 Lib
是第一方图书馆,第三方图书馆如Facebook SDK应该进入供应商
文件夹。
Also the Lib
folder is ment to hold 1st party libraries, 3rd party libraries like the Facebook SDK should go into the Vendor
folder.
另请参阅 ,也就是使用composer安装它(请务必阅读 时使用composer),那么您必须确保您包含 autoload.php
文件,它应该像在引导
In case you can't/don't want to use the recommended way of including the SDK, that is by installing it using composer (make sure you read the notes in Installing CakePHP with Composer when using composer), then you have to make sure that you include the autoload.php
file that ships with the SDK, which should be as simple as requiring it in your bootstrap
require_once APP . 'Vendor' . DS . 'Facebook' . DS . 'autoload.php';
从这里开始,您应该可以使用SDK类所示。
From there on you should be able to use the SDK classes as shown in the docs.
use Facebook\FacebookSession;
FacebookSession::setDefaultApplication('YOUR_APP_ID','YOUR_APP_SECRET');
$session = new FacebookSession('access-token');
这篇关于CakePHP没有找到FacebookSession类问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!