Weiter zu Netlog

noch Sekunden

Developer / Documentation / OpenSocial: which approach to take?

Here we briefly list the different options you can consider when developing an application for Netlog. Consider your approach carefully up front, to avoid running into troubles along the way.

Everything within the Gadget

Since the gadget XML can contain HTML, JavaScript and Flash, it is perfectly possible to create an entire app within the spec XML. An example of this approach is our popular gifts application.


  • Access to the OpenSocial JavaScript functions is very easy. Asking credits, showing the 'share with your friends' dialog, and resizing your application are all done with JavaScript.


  • It is rather hard in this approach to make requests to your own server. Signing makeRequest() calls is rather cumbersome, and the function cannot run simultaneously in different threads. The answer: leverage persistent storage to the maximum, and don't bother trying to sign your makeRequest calls.
  • If your application consists of multiple pages things can get cumbersome pretty quickly, since everything is in one file so you'll need to handle the navigation purely with JavaScript.

In conclusion, you should use this approach only if the HTML+JS of your app is fairly simple, and you do not need to store/retrieve data from your own server. Bluntly put:

use the gadget-only approach if your application consists of a Flash movie and you do not need to make (secure) requests to your own server.

Read this: Tutorial 5: Flash and OpenSocial

Loading an iframe within the gadget + security token (st) authentication

This allows you to handle everything on your own server, accept for some basic initialisation in the gadget. If your application depends heavily on data that you store on your end, and/or it consists of multiple pages, use this approach.

With this approach you use JavaScript within the gadget for only three things: generate a security token, create an iframe (with src attribute pointing to your server and st as GET parameter), and resize the gadget to match the size of the iframe (in that order).

Read this:

  • Tutorial 2: OpenSocial REST API

    Loading an iframe within the gadget + 2-legged OAuth authentication

    Same as above, but with the added benefit that you can send notifications to the user also when he is not on your application. To be more precise, you will need his user ID to do this, so you can send notifications (and for example, give credits) from your own end after the user used your Netlog application at least once.

    The only difference with the above approach is that this time we give you your authentication credentials (OAuth consumer key+token) beforehand, and apart from this you only need the user ID to make OpenSocial REST calls from your own server. This time it is the Netlog user ID that you pass on from within the gadget to your iframe.

    Read this:

  • Tutorial 4: OpenSocial PHP client