A CakePHP Plugin used to interface with the Facebook PHP SDK
PHP
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Controller/Component
Lib
View/Helper
README.md

README.md

CakePHP Facebook Plugin

A CakePHP Plugin used for interfacing with the Facebook PHP SDK.

For a full list of available methods and properties, please refer to the Facebook PHP SDK Overview

Installation

  1. Copy the plugin to app/Plugin/Facebook
  2. Enable the plugin in app/Config/bootstrap.php

Configuration

In your controller:

public $components = array(
    'Facebook.Facebook' => array(
        'appId' => YOUR_FACEBOOK_APP_ID,
        'appSecret' => YOUR_FACEBOOK_APP_SECRET
    )
);

public $helpers = array(
    'Facebook.Facebook' => array(
        'appId' => YOUR_FACEBOOK_APP_ID,
        'appSecret' => YOUR_FACEBOOK_APP_SECRET
    )
);

Usage

The following example shows how to use the FacebookHelper::getLoginUrl method to create a Facebook login link.

echo $this->Html->link(__('Login with Facebook'), $this->Facebook->getLoginUrl(array(
    'redirect_uri' => $this->Html->url('/', true),
    'scope' => 'email,user_interests,user_location'
)));

The following example shows how to use the FacebookHelper::likeButton method to create a Facebook Like Button.

echo $this->Facebook->likeButton(array(
    'href' => $this->Html->url(array('controller' => 'posts', 'action' => 'view', 123), true),
    'send' => 'false',
    'layout' => 'button_count',
    'width' => '450',
    'show_faces' => 'false',
    'action' => 'recommend'
));