问题
I am trying to use the new facebook Graph PHP SDK v4.0 with Yii Framework.
I would like to use Namespaces and the application I am trying to create is a Facebook Page Tab.
I am unable to autoload the facebook SDK
Can someone please help me with a solution?
回答1:
I created a wrapper class for the SDK in extensions/FacebookUtility.php
// Include facebook client library
require_once __DIR__ . '/../facebook-php-sdk/src/facebook.php';
class FacebookUtility extends CApplicationComponent
{
public $apiKey;
public $secretKey;
:
:
public function connect() { ... }
}
Then, in my main.php, under components
'facebook'=>array(
'class' =>'FacebookUtility',
'apiKey' =>'yourapikey',
'secretKey' =>'your secret key',
),
Then, during my login.
$objFacebook = Yii::app()->getComponent('facebook');
// Establish a connection to facebook
$objFacebook->connect();
来源:https://stackoverflow.com/questions/24827508/yii-and-facebook-sdk-v4-0