PHP code example of armetiz / facebook-bundle

1. Go to this page and download the library: Download armetiz/facebook-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

armetiz / facebook-bundle example snippets




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');
    }

}
 bash
$ php composer.phar update armetiz/facebook-bundle
 php

// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Armetiz\FacebookBundle\ArmetizFacebookBundle(),
    );
}
 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');
    }

}