A simple bundle to expose Facebook SDK.
<?php
namespace Acme\DemoBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class HomeController extends Controller {
public function indexAction($facebookId, $facebookToken) {
$facebookSdk = $this->get("armetiz.facebook");
$facebookSdk->setAccessToken($facebookToken);
$userProfile = $facebookSdk->api('/' . $facebookId, 'GET');
}
}
?>
Installation is a quick 3 step process:
Add ArmetizFacebookBundle in your composer.json:
{
"require": {
"armetiz/facebook-bundle": "*"
}
}
Now tell composer to download the bundle by running the command:
$ php composer.phar update armetiz/facebook-bundle
Composer will install the bundle to your project's vendor/armetiz directory.
Enable the bundle in the kernel:
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Armetiz\FacebookBundle\ArmetizFacebookBundle(),
);
}
Finally, add the following to your config.yml
# app/config/config.yml
armetiz_facebook:
enabled: true
sdk:
myApplicationA:
app_id: 1234567890
secret: 1234567890
myApplicationB:
app_id: 0987654321
secret: 0987654321
default: true
enabled: false
This bundle can be configured, and this is the list of what you can do :
Note:
You can retreive each connection using the container with "armetiz.facebook.[sdk_name]".
When you define a "default" connection. You can have a direct access to it with "armetiz.facebook".
<?php
namespace Acme\DemoBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class HomeController extends Controller {
public function indexAction($facebookId, $facebookToken) {
$facebookSdkA = $this->get("armetiz.facebook.myApplicationA");
$facebookSdkB = $this->get("armetiz.facebook.myApplicationB");
$facebookSdkA->setAccessToken($facebookToken);
$facebookSdkB->setAccessToken($facebookToken);
$userProfileFromA = $facebookSdkA->api('/' . $facebookId, 'GET');
$userProfileFromB = $facebookSdkB->api('/' . $facebookId, 'GET');
}
}
?>
How can I help you explore Laravel packages today?