Developing for the social web

No Comments

So you're fresh out of college with a degree in computer science. As you gleefully wait for that one phone call, you discover the computer isn't just what you were taught it'd be. It has metamorphosed into the pervasive social web. Standalone apps have made way for those that reside on the cloud. Data isn't centralized in a database, rather distributed all over the network. And users need to access this data from everywhere. Screen size, power consumption, and network latency are just some of the new variables in the computing equation. Welcome to the real world.

But don't break out in a cold sweat. You have the tools, and the know how. All you need is a little tete-a-tete with the ways of the social web.

First things first. All web apps expose their data via an Application Programming Interface (API). But before you jump into APIs, put you programming skills to use and get a feel for what's in store. Every web app has a bunch of plugins or widgets that lets you embed elements from that service into a webpage.

The Facebook social plugins are a good place to start. Add a Like Button, Recommendations, and Activity Feed to make a static HTML page, dynamic. All with a few lines of HTML. Also look at YouTube Widgets to add videos, a strip of videos, or let them search for videos, with some simple JavaScript.

The APIs

Once you've familiarized yourself with the ways of the social web, it's time to dive in.

1. Facebook Platform. The Facebook Platform is the set of APIs that give you access to content hosted on Facebook. Initially it just allowed development on Facebook.com but now lets you integrate across the web and devices.

Pay close attention to the Facebook Graph API which enables developers to read and write data to Facebook. There's also Facebook Connect set of APIs that enable Facebook members to log onto third-party websites, applications, mobile devices and gaming systems with their Facebook identity.

2. Twitter APIs. The popular micro-blogging site Twitter, has a bunch of APIs too. The TwitterREST API is for accessing all functions on the timeline. Then there's the Search API which fetches top tweets. The Streaming API gives you real-time access to public data.

Make sure you browse through the introductory presentation on developing with Twitter by the tech lead of the Twitter APIs. It's a wonderful introduction to the topic.

3. YouTube APIs. You've used the tools now play with the APIs. There's the Data API which lets you incorporate YouTube functionality into your own app or website. The Player API is what you need if you want control over playback. There's also YouTube Direct which lets a site's users submit content, that can be moderated, and then displayed on the site.

4. Flickr APIs. The photo-sharing service has wrappers or API kits in several languages, but these aren't maintained or supported by Flickr. Take a careful look at Flickr's authentication API as it's only got one of these to authenticate a user from either a web app, a desktop app, or a mobile app.

5. Delicious API. Not that the rest of them aren't. I'm talking about the social bookmarking service, previously known as del.icio.us. Its API is still under development, give you read/write access to the Delicious bookmarks and tags via a HTTP-based interface. Webmonkey has a nice tutorial to help you get started with the Delicious API.

6. Google Maps API. Ever since we've learned to drive, we've got lost. Every site can benefit from a map, which is why Google Maps has a bunch of APIs that allow you to embed a Google Map on a webpage using JavaScript, or in a Flash-based app. Or you can just display static maps that are fast to render and simple to read, without either JavaScript or Flash. These are ideal for low-bandwidth apps such as website for mobile phones. There's also an API for embedding Google Earth data.

7. LinkedIN API. LinkedIN is the social network for professionals. With its APIs you can let users bring their LinkedIn profiles and networks with them to your site or app.

8. Wikipedia API. There is no Wikipedia APi as such. But Wikipedia is based on the MediaWiki Wiki package, and you can use the MediaWiki API to write apps that login, get data from, and post changes to Wikipedia.

If you're interested in APIng in the cloud, you might also want to check out the Amazon EC2 API and the Amazon Web Services (AWS) Toolkit for Eclipse. Here you'll also find various API tools that serve as the client interface to the Amazon EC2 web service. Use these tools to register and launch instances, manipulate security groups, and do a lot more.

The standards

Besides the APIs you need to familiarize yourself with some standards that are prevalent on the web.

1. OAuth. OAuth (Open Authorization) is "the" open standard for authorization. This is how visitors to your site/users of your app share data between sites without handing out their usernames and passwords.

Yahoo's OAauth implementation is fully compliant with OAuth Core 1.0. But OAuth 2.0 is already here and it is not backward compatible with OAuth 1.0. Keep in mind that Facebook's new Graph API only supports OAuth 2.0.

2. OpenID. Look at it as a complimentary service to OAuth. OpenID is "the" open standard that describes how users should be authenticated. It gives users a consolidated digital identity. As of December 2009, there were over 1 billion OpenID enabled accounts and approximately 9 million sites had integrated OpenID consumer support.

3. REST. The HTML protocol did a nice job of serving the web as long as the web was a bunch of static pages. The evolution from static to dynamic required a new software architecture to govern the interactions between the components of the WWW. Enter Representational State Transfer (REST). For most services, REST offers a simple request format and returns a simple response format.

The Languages

You'd have learnt to program in school. More often than not, you'd find very little use for any of the programming languages you excelled at, on the web. But you've got the logic. It's just a matter of semantics and syntax.

1. PHP. Everyone who writes code for a living has their own favourite programming language. It's best if you know them all, it's good if you know several, but you'll do just fine if you know PHP.

PHP is an incredibly popular scripting language. It makes up the majority of Facebook's code-base. Facebook has a lot of developers tools for PHP, such as the PHP SDK, and the PHPEmbed library. PHP also has several implementations of the REST framework, such as Symfony.

You'll find atleast a couple of manuals and books on PHP as there are atoms on this planet. But if you need a concise guide, get yourself a copy of Paul Hudson's PHP Coding Academy or his Practical PHP Programming guide.

Disclaimer: Paul's my editor at Linux Format. And he's the best!

2. Clojure. They taught you Java at school. Develop on it and learn Clojure which is a dynamic programming language that runs on the Java Virtual Machine (JVM) and the Common Language Runtime (CLR). It's influenced by the good things in life such as lisp, prolog, and erlang. There are twitter libraries for Clojure, and it'll also help you with development for Java-based devices such as Android.

Although it's still new, you'll find lots of good documentation on Clojure. My buddy Baishampayan Ghose is writing a slick manual on Clojure.

3. XML. To get serious web traction, you need to master a markup language. XML is what the doctor ordered. It's relevant to website development and plays a crucial role on the social web to deliver data and functionality through AJAX and web services such as SOAP and REST.

4. cURL. Twitter recommends cURL, and I don't disagree. It's a command-line tool based on the libcurl library for transferring data using lots of protocols, such HTTP, SFTP, Telnet, POP3, etc. Also check out Twurl which is Twitter's OAuth-enabled version of curl.

5. Facebook Markup Language (FBML). If you're developing Facebook apps it makes sense to get a feel for their markup language, FBML. FBML develops on top of HTML and allows Facebook Application developers to customize the "look and feel" of their applications.

6. The Yahoo Query Language (YQL). If you'll be interacting with Yahoo-powered web services read up on YQL. YQL is a SQL-like language that lets you query, filter, and join data across web services. Yahoo claims that with YQL, apps run faster with fewer lines of code and have a smaller network footprint.

Talking of optimizing for a particular web service, if you'll be writing for Facebook, learn HipHop for PHP. It's been created by Facebook to save resources on its servers. It is written in some 300,000 lines of C++ and C and is available under the terms of version 3.01 of the PHP License.

A good service doesn't force you to learn a new language. Take for example Twitter which maintains a list of libraries for working with the service from lots of languages, including PHP, Clojure, Perl, Python, etc.

How social projects get done

By now you should have a fair idea about where you need to look and what you need to learn. Before you start scribbling though take a look at how others are doing it. You'll find a lot of guides on writing web-apps, such as Ben Werdmuller's tutorial for writing real-time web applications with XMPP, PHP, and JavaScript.

Disclaimer: Ben was the technical lead of Elgg, which is an open source social networking software. In his IBM developerWorks article he suggests using Openfire which is a XMPP-server written in Java. I have written (the only) books on both Elgg and Openfire. Both software have moved beyond the books, yet they are still pretty cool. But, of course you knew I'd say that!

Tutorials, and books will only get you this far. To get a serious insight into a social web project look at the two shining examples of Open Source web apps -- StatusNet, which powers the micro-blogging service Identi.ca, and Diaspora, touted as the Open Source Facebook.

Points to remember

So you're all set. Here are a few pointers to get you going.

1. Join developer mailing lists. All projects have them. To wait to join till you have a question. The help and advice you'll get from keeping an eye on the flow of information will be eye opener.

2. Read official documentation. Scan through the API methods whether you'll be using them immediately or not.

3. Don't be a one-trick pony. Be a jack-of-all-trades. Build a portfolio of apps. That's your resume.

4. Assemble your build environment. I'm biased so I'll recommend Linux as the base platform, everything else is on the mirror. Right from the Apache web server, Clojure, Subversion, Tomcat, Cocoon, Eclipse, PHP, and the whole shebang.

5. Get on with it. Most APIs require you to register for an API key before you can use their APIs. So get on with it.

Next up: Developing for the smart phone

Comments are closed for this post