If updated now my symfony project to facebook-sdk-v4. My question is now how to integrate it to use in my controllers?
For the old version i had the following line in my autoload.php
//Loading facebook from vendor
require_once __DIR__ . '/../vendor/facebook/php-sdk/src/facebook.php';
then in the controller i could something like that
$facebook = new \Facebook(array(
'appId' => $this->container->getParameter('fb_appid'),
'secret' => $this->container->getParameter('fb_secret')
));
$fb_userid = $facebook->getUser();
without having any use statement in my controller.
Now with version 4.0 its a bit different. There is no facebook.php file anymore in the vendors, therefore i dont know what to require now. And API call differs too, it looks like
FacebookSession::setDefaultApplication('YOUR_APP_ID', 'YOUR_APP_SECRET');
When i execute that, symfony tells me that it cannot load "FacebookSession" from the global namespace, and if i forget the use statement.
Did anyone have experience how to include the new facebook php sdk in symfony2??
Install the SDK via Composer. Therefore add the following line to the require section of your composer.json and execute composer update
afterwards.
"facebook/php-sdk-v4" : "4.0.*"
Facebook SDK will be autoloaded via composer then.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With