I am having a hard time with facebook's SDK documentation. I downloaded the SDK from Github and added it into my PHP project.
Here is the file system:
├── Facebook
│ ├── FacebookAuthorizationException.php
│ ├── FacebookCanvasLoginHelper.php
│ ├── FacebookClientException.php
│ ├── FacebookJavaScriptLoginHelper.php
│ ├── FacebookOtherException.php
│ ├── FacebookPermissionException.php
│ ├── FacebookRedirectLoginHelper.php
│ ├── FacebookRequest.php
│ ├── FacebookRequestException.php
│ ├── FacebookResponse.php
│ ├── FacebookSDKException.php
│ ├── FacebookServerException.php
│ ├── FacebookSession.php
│ ├── FacebookThrottleException.php
│ ├── GraphLocation.php
│ ├── GraphObject.php
│ ├── GraphSessionInfo.php
│ ├── GraphUser.php
│ └── fb_ca_chain_bundle.crt
└── test.php
here is my code so far:
use Facebook\FacebookSession;
use Facebook\FacebookRequest;
use Facebook\GraphUser;
use Facebook\FacebookRequestException;
FacebookSession::setDefaultApplication('*******','******');
$helper = new FacebookRedirectLoginHelper('http://isgeek.eu/fb/FaRepost/return.php');
$loginUrl = $helper->getLoginUrl();
// Use the login url on a link or button to redirect to Facebook for authentication
I get this error
Fatal error: Class 'Facebook\FacebookSession' not found in /homepages/2/d184071366/htdocs/isgeek/fb/FaRepost/test.php on line 9
At updated my PHP version, so the issue does not comme from here. It seems like the PHP files are not found. I read this question (Facebook SDK v4 for PHP Minimal Example) but it does not help.
Where does this comme from?
I found the solution here
I did not code in php for some time now and things have changed. use Facebook\FacebookSession;
is not enough. You need to add a require_once
too.
require_once 'Facebook/FacebookSession.php';