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