CakePHP FacebookSession class not found issue

六眼飞鱼酱① 提交于 2019-11-29 16:47:03
ndm

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

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

See also Cookbook > CakePHP Folder Structure

Use composer or the autoloader that ships with the SDK

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';

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');
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!