PHP code example of akkaweb / cakephp-facebook

1. Go to this page and download the library: Download akkaweb/cakephp-facebook 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/ */

    

akkaweb / cakephp-facebook example snippets


// NOTE: Use instructions in SDK5 Branch if this is a new installation. This branch his no longer supported.

"

Plugin::load('AkkaFacebook', ['bootstrap' => false, 'routes' => true]);

public function initialize(){
    parent::initialize();
    
    $this->loadComponent('AkkaFacebook.Graph', [
	    'app_id' => 'your-fb-app-id',
	    'app_secret' => 'your-fb-app-secret',
	    'app_scope' => 'email,public_profile', // https://developers.facebook.com/docs/facebook-login/permissions/v2.4
	    'redirect_url' => Router::url(['controller' => 'Users', 'action' => 'login'], TRUE), // This should be enabled by default
	    'post_login_redirect' => '' //ie. Router::url(['controller' => 'Users', 'action' => 'account'], TRUE)
	    // 'user_columns' => ['first_name' => 'fname', 'last_name' => 'lname', 'username' => 'uname', 'password' => 'pass'] //not 

sudo php composer.phar update
`
Optional Settings Array
* id 	-> Link id
* class -> Link class
* title -> Link title
* style -> Any html style
* label -> Hyperlink text
	
` echo $this->Facebook->loginLink($options = []); 
`
Default Options
* 'action' => 'like', // like, recommend
* 'share' => true,
* 'width' => 450,
* 'show-faces' => true,
* 'layout' => 'standard' // standard, box_count, button_count, button

` echo $this->Facebook->likeButton($options = []); 
`
Default Options
* 'layout' => 'button_count' // button_count/box_count/button/icon_link/icon/link

` echo $this->Facebook->shareButton($options = []); 
`
Default Options
* 'width' => 50,
* 'height' => 30,
* 'colorscheme' => dark
	
` echo $this->Facebook->sendButton($options = []); 
`
Default Options
* 'width' => 300,
* 'height' => 100,
* 'colorscheme' => 'light',
* 'layout' => 'standard',
* 'show-faces' => false,
* 'kid-directed-site' => false
	
` echo $this->Facebook->followButton($options = []); 
`
Default Options
* 'colorscheme' => light, // light/dark
* 'mobile' => 'Auto-detected',
* 'num-posts' => 10,
* 'order-by' => 'social', // social/reverse_time/time
* 'width' => 550
	
` echo $this->Facebook->comments($options = []); 
`
Default Options
* 'width' => 500
	
` echo $this->Facebook->embeddedPosts($options = []); 
`
Default Options
* 'href' => ''
* 'width' => 500
	
` echo $this->Facebook->embeddedVideo($options = []); 
`
Default Options
* 'href' => 'https://www.facebook.com/facebook',
* 'height' => 300,
* 'hide-cover' => false,
* 'show-facepile' => true,
* 'show-posts' => false,
* 'width' => 500
	
` echo $this->Facebook->page($options = []); 
 echo $this->Facebook->initJsSDK();