CakePHP FacebookSession 类未找到问题 [英] CakePHP FacebookSession class not found issue

查看:28
本文介绍了CakePHP FacebookSession 类未找到问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 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

推荐答案

自定义路径/包需要注册

首先,App::uses() 不是这样工作的.自定义路径/包需要先注册,请参考CakePHP:无法从自定义包加载类

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 custom package

此外,Lib 文件夹用于保存第一方库,Facebook SDK 等第三方库应放入 Vendor 文件夹.

Also the Lib folder is ment to hold 1st party libraries, 3rd party libraries like the Facebook SDK should go into the Vendor folder.

另见Cookbook > CakePHP 文件夹结构

See also Cookbook > CakePHP Folder Structure

如果您不能/不想使用 推荐的包含 SDK 的方式,即使用 composer 安装它(确保您阅读了 使用 Composer 安装 CakePHP 时使用 Composer),那么你必须确保包含 autoloadSDK 附带的 .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 FacebookFacebookSession;

FacebookSession::setDefaultApplication('YOUR_APP_ID','YOUR_APP_SECRET');

$session = new FacebookSession('access-token');

这篇关于CakePHP FacebookSession 类未找到问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆