Facebook Application in 9 Lines of Code

Showing results for 
Search instead for 
Did you mean: 

Facebook Application in 9 Lines of Code

Active Member II
0 3 1,376
Our recently introduced Facebook integration platform is an interesting showcase of Alfresco's Web Script framework.

I've been meaning to provide a quick overview here, but an Alfresco developers life is always busy working towards Alfresco vNext.  However, I had to write something after reading the DZone article 'Apache Wicket Facebook Integration'.

The article provides full source code to the simplest of Facebook applications; List My Friends.  It's cool to see a framework that assists Java developers build Facebook apps (it's mostly a PHP world), but this simplest of Facebook application requires 100 lines of code in Wicket.  And I don't think that's all of it, as there must also be configuration to complement the code.

Here's the equivalent in Alfresco... create the following files in the Alfresco repository:

app.[insert api key here].js
app.id='[insert application id here]';
app.secret='[insert application secret here]';

<shortname>List My Facebook Friends</shortname>

<#list facebook.friends as friend>
<fb:name uid='$friend'/></#if friend_has_next>, </#if>

That's a total of 9 lines of code.  There's nothing else to it.  Not even a build step.  Just register the application with Facebook.

That's 1/10th the lines of Wicket, or 300 characters vs 4000.

Once the 9 lines of code have been developed, you'll want to go through a test, code, test cycle.  Web Scripts make this simple, just change the code and hit refresh in the browser.  Wicket's Java equivalent just doesn't allow this.

Facebook apps are mostly content oriented in the context of a social graph. This is where Alfresco really shines, as of course, it provides a full set of content management services all accessible in Web Scripts.

Facebook Integration is just one showcase of Web Scripts.  The same principles apply to developing an Alfresco application, dashlet, JSR-168 portlet, iGoogle gadget, Atom feed, JSON data service, RESTful API, ...
Active Member

Your code looks nice and compact. The comparison with that Wicket WIKI item (that somehow got posted to DZone) isn't entirely fair though, because what you see there is actually the integration code. Also, test - code - test works fine with Wicket, especially when using something like JavaRebel.

It's a nice thing to look at though. ATM, Wicket doesn't really have specialized components for handling external REST content. Would be a fun exercise to write something sleek.


Active Member
Wow, comparing a general web application framework to a content management system...apples to oranges?

How many lines of code in that 100 line wicket app are generic and can be packaged into a jar an application author can drop in? If I look at the wiki page you've created I would say that the actual Wicket application code consists of: 1 line of markup, and 6 lines of actual java code (not counting class/method declarations that ides generate for you).

As far as refreshing goes you are not completely on target. If you launch a wicket app in debug mode java's hotswap can accommodate you a pretty big percentage of time. In development mode wicket also reloads markup and property files automatically when they are modified.

So next time, try to get your facts a little more straight. No Wicket doesnt have built in REST querying support , its a web application framework.
Active Member
Thanks for your comments.

I'm not really interested in comparing apples to oranges.  I'm more interested in how we can make it really easy to develop Facebook apps on the Java platform - using whatever kind of tool.  As I said, it's cool that Wicket is allowing this.  I like Wicket and its approach.  What I would like to see is the next step - a pre-built Wicket package that hides all the Facebook plumbing (which is not that easy to decipher) - a Facebook Java developer platform.  It seems the core of the code is there, perhaps it's in the works.  If I had spare time, I'd love to contribute to such a thing.

With these kinds of platforms we might see more interesting Facebook apps.