I\'m trying use Facebook lib v4 to create a simple Facebook login.
I\'m following Facebook guide and I\'m stucked at begnning, CakePHP is not finding FacebookSession
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
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');