Thursday, May 29, 2008

The Sith Lords Back Ringside!

This charming picture of Emperor Palpatine and many other beloved Star Wars characters showed up on the Ringside cam and thought it was worth sharing. I guess they know a good thing when they see it. Go Ringside!

Wednesday, May 28, 2008

Surprise! Facebook's login.php has Changed

I just noticed that one of my deployed Facebook applications was no longer working properly when it was being accessed from outside Facebook. This application allows users to make comments on abstract artwork (Its is at www.FulcrumGalleries.com). It is also running on Facebook as an application called What is Art. It is built with the Ringside Newtwork's Social Application Server which allows this type of dual deployment though the use of a Javascript widget.

This application can use Facebook to log users in when they are using the What is Art application directly from the Fulcrum website. It does this by deferring to Facebook for authentication. This is achived by following Facebook's posted authentication rules for web and desktop apps located here.

What I started seeing is quite different than the posted procedure. Originally, an application could redirect to login.php with an api_key as a parameter with the intention of logging in to a specific application. Login.php would then redirect to the calling application's callback_url with an auth_token which could then be converted into a Facebook session by calling auth.getSession. You would then use that session for all future API calls.

Well now I am seeing a different behavior in login.php. It now returns a parameter called session when it calls the callback_url. Session looks like this:
{"session_key":"263101aaf6065b08763196df-558462736","uid":"558462736","expires":0,"secret":""}
As you can see, the session parameter has the actual session_key inside it already, completely allowing you to skip the call to auth.getSession! I guess this is a time saver but supporting this change took some re-coding to get my app working again. It might be a good idea to start running a functional test against login.php daily just in case it changes again.

Wednesday, May 21, 2008

Why I Love Javascript


You can't get errors like this anywhere else.

I Mock PHPUnit

I need to write PHPUnit tests for an OpenSocial class I am implementing in PHP and I am new to PHPUnit. The class required another class, a security token as input and I did not want to create a real token for my test. To my surprise, I discovered that PHPUnit has the ability to create Mock Objects built in. It was so easy to do I felt compelled to post this example which I dug up here.

If I want to create a Mock Object for the class RingsideGadgetToken for example and it has a default (No argument constructor) all I had to do was this:

public function createMockToken(){
$uid_='100000';
$api_key_='4333592132647f39255bb066151a2099';
$api_secret_='b37428ff3f4320a7af98b4eb84a4aa99';
$token=$this->getMock('RingsideGadgetToken');
$token->expects($this->any())->method('getAppId')->will($this->returnValue($api_key_));
$token->expects($this->any())->method('getOwnerId')->will($this->returnValue($uid_));
$token->expects($this->any())->method('getViewerId')->will($this->returnValue($uid_));
return $token;
}

And I had a fully functional mock RingsideGadgetToken. If I had wanted to I could have failed if a method was called more than once (expects($this->once())) or a specific number of times (expects($this->exactly(4))). Below is the complete example I found in Sebastian Bergmann's presentation referenced above which got me started:


require_once 'PHPUnit_Framework_TestCase';

class SubTest extends PHPUnit_Framework_TestCase
{
public function testStub()
{
$stub = $this->getMock('SomeClass'); $stub->expects($this->any())->method('doSomething')->will($this->returnValue('foo'));

// Calling $stub->doSomething() will now return
// 'foo'
}

}
?>

Anyway, I was so pleasantly surprised, I thought it worth talking about. There is a great guide to PHPUnit I came across as well at http://www.phpunit.de/pocket_guide/index.en.php

Tuesday, May 20, 2008

Facebook and OpenSocial Interoperability Ideas - Component Reuse



I have been looking at how OpenSocial can be integrated into the Ringside Social Application Server over the past few weeks and have come up with two different models for integration. Which model we should adopt first really turned out to be decided based on the maturity of the OpenSocial Platform but I will talk more about this in a future posting. Right now lets talk about the model I am working on now, The Component Reuse Model.

In this model, The Ringside server becomes an OpenSocial gadget server. Shindig (Apache's implementation of an OS gadget server) is embedded in our product and it servers up the Ringside Server's social graph using an OpenSocial Javascript container and data model. This opens up some interesting possibilities.
  1. Offline OS Development: Your Ringside server can now be used to develop OS apps offline, on your own box the same way that you can already do this for Facebook applications.
  2. Hosting OS Apps: OpenSocial applications could be run as peers to Facebook apps on the same system, sharing the same social graph, in essence providing a portable application format which would allow your app to run on Orcut or Ringside for example. Ringside servers now also could benefit from the reverse of this and gain the use of existing OS apps available today (though some minor changes might be required to run in our container).
  3. Running OS Apps in Facebook: If you can deploy a OS Gadget as a Ringside application it gains the ability to authenticate against Facebook (since the platform can already do this). Once this is set up you would be displaying Facebook's social graph inside your OS application. Since it was deployed to a Ringside server as an iframe app, it could be easily registered with Facebook as an application and the Ringside server would automatically handle conversion of Facebook's social context to an OS security token.
All of this can be accomplished just by integrating Shindig into our existing Social Application Server as it stands now. A first draft of this should ship this week in the Ringside Server beta3 release.

Monday, May 19, 2008

Standup Haiku

When I mentioned that our daily development stand-up meetings were to long, one of the developers where I work (Ringside Networks) told me that my status was usually the longest so why should I object to the overall length of the meeting?

I thought, good point, but how to sharpen my status comments to a fine point and yet keep them informative and though provoking? The answer came to my mind immediately: Haiku. A simple form of poetry consisting of three lines of text where the first and last lines have only five syllables and the middle one seven. I must say this worked. Not only does everyone seem to listen more keenly but they ask the questions when I am done. Below is a sample, my status for today.

Am working on trails.
Seven and eight are done now,
Gadget server, Ready.

I am no poet, but the Haiku form sure did the trick.

Followup: This became far more popular than I thought and I have been asked to do this daily for a while (I don't know how long I can keep it up). They can be read at http://wire.tumblr.com/.