I have put the Facebook SDK files into the protected/helpers
directory, from which I autoload classes and 3rd Party helpers for my Yii Application.
When one of my projects involved Facebook Login, I've came up with this simple and quick solution, using the Yii::app()->params
to achive the inheritance of an object property throughout the application.
// don't mind this $facebook variable, it's just a shortcut in this method
Yii::app()->params['facebook'] = $facebook = new Facebook(array(
'appId' => '148966221932337',
'secret' => 'a52ce7b4a0cd5d517c6ada53fc77cde7',
'cookie' => true,
));
$user = $facebook->getUser();
Thereby, I have the Yii::app()->params['facebook']
, set or unset, available throughout my application and in that way I can access the Facebook API SDK wherever in my application, however I do belive that this is not a good solution.
Are there any, better, solutions for implementing Facebook API SDK into the Yii Framework Application?