0
votes

I have need your help about Facebook SDK with PHP in Yii Framework. But when I put all file in php-sdk which download from developer.facebook.com into portected/vendor and config in config/main.php. In file I use code:

require_once (Yii::app()->basePath . '/vendors/facebook-php-sdk/autoload.php');

use Facebook\FacebookSession; use Facebook\FacebookRequest; use Facebook\GraphUser; use Facebook\FacebookRequestException; use Facebook\FacebookRedirectLoginHelper;

But when I use: FacebookSession::setDefaultApplication(api_key,api_secret);

It shown me an error:

Class Facebook FacebookSession not found in......

Can you help me about this error.Thank all.

2

2 Answers

0
votes

Please include all class files.

require_once Yii::app()->basePath . '/vendors/facebook-php-sdk/autoload.php';       
require_once Yii::app()->basePath . '/vendors/facebook-php-sdk/src/Facebook/FacebookSession.php';
require_once Yii::app()->basePath . '/vendors/facebook-php-sdk/src/Facebook/FacebookRequest.php';
require_once Yii::app()->basePath . '/vendors/facebook-php-sdk/src/Facebook/GraphObject.php';
require_once Yii::app()->basePath . '/vendors/facebook-php-sdk/src/Facebook/GraphUser.php';
require_once Yii::app()->basePath . '/vendors/facebook-php-sdk/src/Facebook/FacebookSDKException.php';
require_once Yii::app()->basePath . '/vendors/facebook-php-sdk/src/Facebook/FacebookRequestException.php';

use Facebook\FacebookSession;
0
votes

Maybe you try this :

session_start();
define('FACEBOOK_SDK_V4_SRC_DIR', './facebook-php-sdk-v4/src/Facebook/');
require_once("./facebook-php-sdk-v4/autoload.php");

use Facebook\FacebookSession;
use Facebook\FacebookRedirectLoginHelper;

just only use "./facebook-php-sdk-v4/autoload.php" in your project