faceplugs A wrapper for facebook plugins.

  1. Requirements
  2. Installation
  3. Usage
  4. Resources

A wrapper for Facebook plugins using the Javascript SDK and the Open Graph protocol.

All Facebook plugins are available.

Current Version: 1.7.1

Requirements

Developed and tested on Yii 1.1.5-10. Should work on all 1.1.x branch.

Installation

Normal

Download and extract the tarball to your extensions folder.

Git Submodule

Alternatively, you may checkout the project as a submodule in Git. This will allow you to update to the latest version right in your Git-enabled project. More on Git submodules. ~~~ $ git submodule add git@github.com:digitick/yii-faceplugs.git protected/extensions/faceplugs $ git submodule init $ git submodule update ~~~

Usage

Application ID

Some plugins will not work without a Facebook application ID. The easiest way is to set it for all facebook plugins in your site in your Yii configuration file, as the 'fbAppId' parameter :

return array(
[...]
    // application-level parameters that can be accessed
    // using Yii::app()->params['paramName']
    'params' => array(
        'fbAppId' => '123456789',
    ),
);

Note that you can override this setting when creating the widget.

You may also set the application ID for all plugins of the same type. In your Yii configuration file :

return array(
    'components' => array(
        'widgetFactory' => array(
            'widgets' => array(
                'LiveStream' => array(
                    'app_id' => '123456789',
                ),
            ),
        ),
    ),
);

Finally, you can set the application ID at each instance of plugin creation, this is done by passing the 'app_id' parameter.

Creating the widget

The extension uses the javascript SDK version of the facebook plugins, which work with the Open Graph protocol.

Open Graph properties, except for 'url', are passed as the 'og' parameter to the plugin.

$og = array(
    'title' => 'The coolest site on the WWW',
    'type' => 'website',
    'site_name' => 'My Awesome Site',
    'image' => $this->createAbsoluteUrl('/images/logo.gif'),
);

To instantiate the plugin, pass the Open Graph properties and the URL of the current page. The application ID should also be set if it isn't defined in the config file.

$this->widget('ext.faceplugs.LikeButton', array(
   'app_id'=>'APPID', // not needed if set in Yii configuration file
   'url' => $this->createAbsoluteUrl('/'),
   'og' => $og
));
Setting options

All the Facebook plugins have options, check the Facebook plugins documentation pages or simply look at the classes. Options are set as normal widget parameters.

$this->widget('ext.faceplugs.LikeButton', array(
   'url' => $this->createAbsoluteUrl('/'),
   'og' => $og,
   'layout' => 'button_count',
   'action' => 'recommend',
   'colorscheme' => 'dark',
));
Setting plugin options

These are set as normal widget parameters, and control the initialization and behavior of the plugin.

  • status : Check user's login status.
  • cookie : Enable cookies to allow the server to access the session.
  • xfbml : Parse XFBML.
  • async : Load the Facebook init script asynchronously.
  • debugMode : When active, it loads the debug version of the SDK (en_US only).
Setting the locale

In normal use, the plugin loader will attempt to use the locale of the Yii application automatically. However, not all locales defined by Yii are available in Facebook. Some common fallbacks have been defined (should cover 98% of all internet users), but in some cases you may want to define the locale manually. This is done by passing the 'locale' parameter on widget creation.

Resources

Version History
12 1
28 followers
2 932 downloads
Yii Version: 1.1
License: LGPL-3.0
Category: Web Service
Developed by: ianaré
Created on: Jan 21, 2011
Last updated: 11 years ago

Downloads

show all

Related Extensions