Sandbox live with OpenSocial 0.8 support

Tuesday, September 9, 2008 at 6:37 PM



Three months and many, many Shindig commits after the OpenSocial 0.8 specification was finalized this past May, we are happy to announce that the sandbox now has support for the updated JavaScript API. Starting today, you can begin the process of updating your apps to use OpenSocial 0.8 -- just add to your application's ModulePrefs element and start coding!

The most substantial change in the updated API concerns the way user and app data is requested. With the introduction of the opensocial.IdSpec class, you will have to make some changes in order for your application to fetch or update data. To illustrate these changes and help get you started, here's a quick application that retrieves both the application's owner and the friends of the current user:

<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="My first OpenSocial app">
<Require feature="opensocial-0.8"/>
</ModulePrefs>
<Content type="html">
<![CDATA[
<script type="application/javascript">
function request() {
var req = opensocial.newDataRequest();
var idSpec = opensocial.newIdSpec({'userId':'VIEWER', 'groupId':'FRIENDS'});

req.add(req.newFetchPersonRequest(opensocial.IdSpec.PersonId.OWNER), 'owner');
req.add(req.newFetchPeopleRequest(idSpec), 'viewerFriends');
req.send(response);
};
function response(data) {
if (!data.hadError()) {
var owner = data.get('owner').getData();
var viewerFriends = data.get('viewerFriends').getData();
}
};
gadgets.util.registerOnLoadHandler(request);
</script>
]]>
</Content>
</Module>

For more on the data request updates, see this article on requesting data in OpenSocial, now updated for version 0.8.

Note that this is only an initial release of the updated JavaScript API and several other features defined in the full 0.8 update are not available with this release, namely REST/JSON-RPC APIs, lifecycle events, extended network distance, and new profile fields such as PRESENCE.

Along with support for the new JavaScript API, the infrastructure behind the existing API has also been updated to use the Shindig enhancements with a special adapter. Your existing applications should continue to work as they have before (as long as you keep in your application's ModulePrefs element), but you should test them extensively in the sandbox to verify that there aren't any edge cases that cause your apps to break. If you do run into problems, make sure to let us know by filing a new issue in the public tracker and continue your development on prod.sandbox.orkut.com which is configured identically to production orkut.

OpenSocial 0.8 support is only available in the sandbox at present, so please wait to submit your new applications until 0.8 is rolled out to production orkut. We will post a new update on this blog when this is ready.

Have any questions or comments? As always, please feel free to post them in the orkut Developer Forum or stop by the official OpenSocial IRC channel at irc.freenode.net#opensocial during our regular office hour block every Tuesday and Thursday from 1:00 p.m. to 3:00 p.m. PDT.