armetiz / facebook-bundle
A simple bundle to expose Facebook SDK
Installs: 5 787
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 2
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=5.3.3
- facebook/php-sdk: >=3.1.1
- symfony/symfony: >=2.1
This package is not auto-updated.
Last update: 2022-02-01 12:21:31 UTC
README
A simple bundle to expose Facebook SDK.
Usage example
<?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
Installation is a quick 3 step process:
- Download ArmetizFacebookBundle using composer
- Enable the Bundle
- Configure your application's config.yml
Step 1: Download ArmetizFacebookBundle using composer
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.
Step 2: Enable the bundle
Enable the bundle in the kernel:
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Armetiz\FacebookBundle\ArmetizFacebookBundle(), ); }
Step 3: Configure your application's config.yml
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
Configuration
This bundle can be configured, and this is the list of what you can do :
- Create many SDK.
- Define specific app_id / secret for each SDK.
- Disable this bundle. This options is optional and default value is true.
- Disable each SDK. This options is optional and default value is true.
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'); } } ?>