Loadsys

LoadStr - A Loadsys Blog

A Web Development Company Specializing In Standard-Based Web Design and the CakePHP Framework.

Browsing ‘CakePHP’

CakePHP Social Networking Plugin

Monday, October 26th, 2009

We started working on Socnet plugin that will allow your cake apps to be easily integrated with most social network sites. For now, we coded and released FacebookAuth component, which will allows to specify which actions require facebook authentication and redirects to facebook for authentication.

Installation

To add FacebookAuth component to your project, please do the following:

1. Download the plugin code from http://github.com/loadsys/socnet and extract all the code into plugins/socnet.

2. Create an application with Facebook at http://www.facebook.com/developers/createapp.php. Set your Connect URL to <your URL>/socnet/facebook/connect.

3. Add the following configuration paramters (Configure::write):
Socnet.Facebook.enabled[0,1] - a flag to disable/enable Facebook support
Socnet.Facebook.api_key - application key (from Facebook)
Socnet.Facebook.app_secret - application secret (from Facebook)

Controller Requirements

Load FacebookAuth component where needed and specify actions that require facebook authentication:

class FacebookFriendsController extends AppControoler {
var $components = array('socnet.FacebookAuth');
var $helpers = array('socnet.Facebook');

function beforeFilter() {
parent::beforeFilter();
$this->FacebookAuth->requireLogin('index');
}

function index() {
...
}
}

Layout Requirements

Facebook helper provides all the methods needed to setup Facebook in your layout.

# Use <?php echo $facebook->htmlTag(); ?> to render the html tag. This function will setup all necessary namespaces.
# Include this line <?php echo $facebook->jsScript(); ?> somewhere in the body. This library is needed for rendering FBML scripts (ex. <fb:connect-button />).
# Add this line <script type=”text/javascript”><?php echo $facebook->jsInit(); ?></script> before </body> tag.

Please look at the sample layout file in views/layouts/facebook.ctp inside the provided plugin.

You can test the plugin integration by going to /socnet/facebook/friends. If everything is setup properly, you should get redirected to facebook for login and then see all your friends thumbs.

CakePHP Comment Plugin

Monday, September 14th, 2009

The goal of every programmer is to write as little code as possible.  It can only be achieved by re-using code that you already wrote.  That is why we all use CakePHP in the first place right?  Fortunately, cake allows us to create plug-ins that we could just drop in into our projects and be done with it.

For quite a few of our projects, especially social applications, we had to add commenting.  In addition, we typically had to allow users to comment on everything (photos, posts, news, articles, etc…). Here is the solution we came up with that worked very well:
(more…)

Close
E-mail It