Downloads

Google Ad

Facebook Plugin v2.0 -- Graph System!

Date: Mon, Jul 19th 2010, 02:20 Author: nick Views: 54473 Comments share

CakePHP Facebook Plugin

Info:
Get it:
  • Download Now
  • git clone git://github.com/webtechnick/CakePHP-Facebook-Plugin facebook
CakePHP Facebook Plugin v2.0 is here! With the help from Theaxiom (https://github.com/theaxiom) the popular CakePHP Facebook plugin is now updated to the newest PHP SDK which features among other things full access to the much anticipated Facebook Graph System.

New Features

Along with access to the new SDK, I've implemented some great new fbxml features
  • Like (let your users like what they find on your site with their friends)
  • Activity Feed (Display your application's and friends activity)
  • Friend Pile (Display your application's friends)
  • Recommendations (Display your recommendations based on your current url)

Some Examples of the newest features are:
  1. //Like Button
  2. $facebook->like(); // => standard like button
  3. $facebook->like(array(
  4.   'font' => 'veranda',
  5.   'layout' => 'button_count',
  6.   'action' => 'recommend',
  7.   'colorscheme' => 'dark'
  8. )); // => customized like button
  9.  
  10. //Activity Feed
  11. $facebook->activity(); // => app activity widget
  12. $facebook->activity(array(
  13.   'colorscheme' => 'dark',
  14.   'bordercolor' => 'black',
  15.   'font' => 'arial',
  16.   'width' => '250',
  17.   'height' => '200',
  18.   'header' => 'false',
  19.   'recommendations' => 'true'
  20. )); // => customzied activity widget including recommendations
  21.  
  22. //Recommendations Widget
  23. $facebook->recommendations(); // => recommendations of current page
  24. $facebook->recommendations(array(
  25.   'colorscheme' => 'dark',
  26.   'bordercolor' => 'black',
  27.   'width' => '250',
  28.   'height' => '200',
  29.   'header' => 'false'
  30. )); // => customized recommendations widget
  31.  
  32. //Friend Pile Widget
  33. $facebook->friendpile(); // => standard friend pile
  34. $facebook->friendpiile(array(
  35.   'width' => 200,
  36.   'numrows' => 3
  37. )); // => customized friend pile

Feature Improvements

Along with the newest Helper features there is an feature enhancement as well.
  • FacebookHelper::logout() Now accepts CakePHP array urls as valid redirect options

Example:
  1. //Normal logout
  2. $facebook->logout(array(
  3.   'redirect' => 'users/logout'
  4. ));
  5.  
  6. //Same as above
  7. $facebook->logout(array(
  8.   'redirect' => array('controller' => 'users', 'action' => 'logout')
  9. ));

1.x to 2.x Migration Guide

There are a few changes you should be aware of before upgrading your application to the newest version 2.0.
  • FacebookHelper::loader() is now deprecated. Remove it from your layout.
  • ConnectComponent::getUserInfo() is no longer available, use ConnectComponent::user() instead.
  • config/facebook.php needs to be updated.
  • FacebookHelper::init() no longer takes in extended permission options, remove any of these extended options from your $facebook->init() call in your layout.
  • FacebookApi class is now FB for short use App::import('Lib','Facebook.FB'); for easy access to the full Facebook API.

New Configuration File Example:
  1. app/config/facebook.php
  2. $config = array(
  3.   'Facebook' => array(
  4.     'appId' => 'YOUR_APP_ID',
  5.     'apiKey' => 'YOUR_API_KEY',
  6.     'secret' => 'YOUR_SECRET',
  7.     'cookie' => true,
  8.   )
  9. );

New ConnectComponent::user() Examples:
  1. var $components = array('Auth','Facebook.Connect');
  2.  
  3. function beforeFilter(){
  4.   //Get all the details on the facebook user
  5.   $this->set('facebookUser', $this->Connect->user());
  6.  
  7.   //retrieve only the id from the facebook user
  8.   $this->set('facebook_id', $this->Connect->user('id'));
  9.  
  10.   //retrieve only the email from the facebook user
  11.   $this->set('facebook_email', $this->Connect->user('email'));
  12. }


New Layout Example:
[geshi=html] html(); ?> Facebook Plugin Example init(); ?>
New API Examples:
  1. App::import('Lib', 'Facebook.FB');
  2.  
  3. //PHP 5.3
  4. FB::api('/me'); //graph system call to /me
  5.  
  6. //PHP < 5.3
  7. $FacebookApi = new FB();
  8. $FacebookApi->api('/me');

Enjoy v2.0

I hope you all enjoy version 2.0. As always, if you like the plugin, have a question, concern, or feature request please post a comment.

If you use the plugin and want to help maintain it please consider a donation.

Enjoy!
Nick