Facebook Application in 9 Lines of Code

cancel
Showing results for 
Search instead for 
Did you mean: 

Facebook Application in 9 Lines of Code

dcaruana
Active Member II
0 3 1,538
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]';

listfriends.post.desc.xml
<webscript>
<shortname>List My Facebook Friends</shortname>
<url>/facebook/listfriends/</url>
</webscript>

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

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, ...
3 Comments