Developer / Documentation / The OpenSocial API

Introduction to openSocial

Netlog fully supports the OpenSocial 0.8 standard, as well as some Netlog-specific extentions to it.

Learning OpenSocial is easy: it's all just basic HTML and JS, or (optionally) REST calls if you are working with social data from an external app.


Embedding an external application (e.g. written in flash or PHP) is as easy to embed in your app as in any web site.

The OpenSocial API allows your app to fetch and interact with Netlog's social data: the person currently using the app, profile information, friends, posting activities or notifications, etc...

The spec XML file

Each OpenSocial app starts from a Specification .XML file, which contains some basic info about the app, as well as the actual HTML and JS of the app itself. The most basic Hello World spec XML file looks like this:

 <Module>
 <ModulePrefs title="Hello World!">
 <Require feature="opensocial-0.8" />
 </ModulePrefs>
 <Content type="html">
 <![CDATA[
 <!-- HTML and JS content be here, just as if this were the <body> content of a web site -->
 <script type="text/javaScript">alert(\'Hello world!\')</script>
 <h2>Hello world!</h2>
 ]]>
 </Content>
 </Module>
 

Two remarks up front:

  • Porting your existing web site/app to an OpenSocial one can be fairly straightforward.
    For example, use JS to insert an iFrame element in the DOM, with the src pointing to the external location of your app. From - within - your iframe-embedded app you can still obtain social data, using REST calls.
    Or for flash apps, one possible approach is to embed the flash opbject in the XML spec and use flashvars to pass on the OpenSocial-fetched data.
  • To use the Netlog-specific extentions in your OpenSocial app you need to include
    <Require feature="netlog" />
    in the ModulePrefs section of your spec.

    The Credit payments extension is separate, and requires
    <Require feature="payment" />

Ready to get your feet wet? Start playing around with the Netlog OpenSocial Sandbox!

Note that, if you want to distribute your app on Netlog, your application will go through a moderation process. Make sure to read our brief Application Guidelines. After that, you might want to get in touch to get your app to our users.

Read more...

OpenSocial was originally conceived by Google (though it's open-source), and they have extensive documentation about it: Careful: some documentation there applies only to OpenSocial 0.9, which we do not support (yet).