Steps towards Opensocial 0.7 API Support

Get ready for OpenSocial 0.7!  On Monday, we updated our gadget server to support more 0.7 features, and fixed some bugs that prevented proper 0.7 API usage.  Fixes range from better content fetching to new view support and much more.  We highly recommend that every developer upgrade their applications to use 0.7 -- it will be the first supported stable API on Orkut, MySpace and hi5.

So, let's get your app up and running in 0.7.  First you'll want to edit your XML module to require OpenSocial 0.7:

     <Require feature="opensocial-0.7"/>

If you've been using _IG_FetchContent() or opensocial.MakeRequest() now's the time to convert to gadgets.io.MakeRequest().  This new call allows you to fetch XML, JSON or Feed content while also allowing for GET request, POST requests and custom headers.  In a future update, we'll also support signed-requests, so you can be sure that the data you're receiving is valid.  Here's a quick example of POSTing to a REST endpoint and fetching the results:

     gadgets.io.makeRequest("http://api.hi5.com/rest/test/echo",
                 myCallback,
                 {CONTENT_TYPE: gadgets.io.ContentType.DOM,
                  METHOD: "POST",
                  POST_DATA: "message=moooooo"});

If you're using the country/lang fields in opensocial.getEnvironment().getParams() you'll want to switch to using code like the following.

    var lang = gadgets.Prefs.getLang();
    var country = gadgets.Prefs.getCountry();

Note that fetching a Hi5AuthToken is still retrieved in the same manner, except you use gadgets.views.getParams() now.

There's a new way to get user data in 0.7.  Instead of a free form NAME field, we now have an OpenSocial.Name object that includes family name, given name, prefixes and suffixes.  The opensocial.Person.getDisplayName() call remains the same.

In 0.6, you could determine the type of page your gadget was running on by calling various surface calls.  These have now all moved to gadgets.views namespace.  To use these calls, add the proper feature requires tag like so:

   <Require feature="views"/>

In your app you can call gadgets.views.getCurrentView() to get the current view, and gadgets.views.getSupportedViews() to find all supported views.  You can also use separate <Content> tags to target different portions of your gadget XML to specific views.  Here's a snippet which has shared default data and custom content for the profile view:

  <Require feature="views"/>
      .....
  <Content type="html" view="profile">
     Content visible on profile...
  </Content>
  <Content type="html" view="default,profile">
      Content visible on profile and default
  </Content>



Leave a comment

Recent Entries

  • OpenSocial 0.8 Moved To Live Environment

    We have now finished the migration of the Platform in production to OpenSocial v0.8. We'd like to thank the developers who helped test 0.8 while...

  • Translation Service for OpenSocial Applications on hi5

    Reaching a Wider Audience: Community-based Translations for Applications Hi5 has a large audience in Spanish-speaking markets, Thailand, Romania, Portugal, and many other countries. How much...

  • OpenSocial 0.8 In Beta On hi5

    Following close behind the release of the OpenSocial 0.8 specification two months ago, we have been hard at work implementing it, and are happy to...

  • Statistics API Available on Sandbox

    The Statistics API that we announced two weeks ago is available on sandbox. Please use the endpoints described in the earlier post, prefixed with http://sandbox.hi5.com/rest....

  • hi5 Providing Library For Templates

    The hi5.template library is a browser side, Javascript library which enables you to fuse Javascript data and logic into your HTML. It simplifies writing...

Close