Getting familiar with applications in the itimes environment
Each OpenSocial container has a different development experience. This section will familiarize you with the process of developing applications specifically for itimes.
| Activity stream | A collection of activities created by OpenSocial applications on behalf of itimes users. These activities are mixed with other notifications in the "friends update" box on the itimes home page. |
| Application | Third party code that uses the gadgets and OpenSocial APIs to extend the itimes experience. |
| Add Application page | Add application page listing all available applications. |
| Application preview page | A page unique to each application where users can see the description and preview of the app and prevent it from posting to their activity stream. For users who do not have the app installed, the page doubles up as the application install page. |
| Manage Application page | Manage Application page lists all applications installed by a user and allows the user to add, remove and submit for approval. |
| Application specification | An XML file that defines the application. Syntax is based on gadget XML. |
| Canvas View | The full page view of an application. |
| Profile View | The View of an application on a user's profile |
| Preview View | The view of an application on the Application Preview page. |
| View | The location where an application is displayed. In itimes, applications can be displayed on either of the Canvas, Profile or Preview views. |
Some privileges must be granted for the application to function, but you can also choose whether to allow the application to post to your activity stream. Check the boxes next to the optional permissions you wish to grant to the application."
This application is automatically installed onto your page."
Click on 'Go to application'. You are automatically redirected to the Canvas page. Now if you return to the Manage Application page, you will see the newly installed application listed on the page."
Now that you have learned the basics of installing and updating applications, here are some tips and tricks that will help you build robust social applications for itimes:
OpenSocial applications are a new type of application, based on the gadgets technology, but extended to interact with social data retrieved from a website from a website (also referred to as a container) that supports the OpenSocial API. itimes is an example of an OpenSocial container and this section focuses on the development aspects of working with OpenSocial applications specifically within the itimes environment.
itimes provides several query string parameters that give one additional data about the context in which one's application is running. These parameters can be parsed manually using window.location.href Alternatively, one can use the gadget convenience function gadgets.util.getUrlParameters. Below is a list of available parameters with their corresponding example values:
| Name | How to retrieve | Example value |
| Country | gadgets.util.getUrlParameters()["country"] | US |
| Language | gadgets.util.getUrlParameters()["lang"] | en-US |
| Owner ID | gadgets.util.getUrlParameters()["owner"] | 12345678901234567890 |
| Viewer ID [1] | gadgets.util.getUrlParameters()["viewer"] | 12345678901234567890 |
| Parent URL | gadgets.util.getUrlParameters()["parent"] | http://sandbox.itimes.com |
| Gadget URL | gadgets.util.getUrlParameters()["url"] | http://example.com/gadget_specification.xml |
| View Name | gadgets.util.getUrlParameters()["view"] | canvas |
| View Parameters | gadgets.util.getUrlParameters()["view-params"] | {"foo":12345,"bar":"Bar value"} |
[1] Only available if the viewer has the gadget installed.
When the Views feature is included, one can obtain the current view by calling the gadget.util.getCurrentView() method which returns a gadgets.views.View object. See Available views in itimes for a listing of views that may be returned by this call.
The following example demonstrates how to get the Current view and conditionally execute a code against the returned value:
One can obtain the available View objects by calling gadgets.views.getSupportedViews:
var supported_views = gadgets.views.getSupportedViews();
The object returned by the getSupportedViews call contains gadgets.views.View objects representing all of the available views in itimes, indexed by View name. Currently, these are:
| View | Code to retrieve |
| Profile | supported_views["profile"] |
| Canvas | supported_views["canvas"] |
| • | Profile and DASHBOARD correspond to a user's profile view. Profile URLs look like: |
| http://www.itimes.com/users/username |
|
| • | Canvas and FULL_PAGE correspond to the maximized view of an application. Canvas URLs look like: |
| http://sandbox.itimes/os_application.php? uid=xxx&app_id=xxx&mod_id=xxx | |
| • | Default does not correspond with any itimes view. This view is returned for compatibility with the multiple content section feature of the gadget specification. You should not use this view for navigation. |
In addition to requesting a view by name, you can also obtain a view by using a ViewType object. This allows you to obtain a type of view with specific properties without referring to the view by name.
The following table shows you how ViewType objects may be used and which views they map to on itimes:
| Name | Code to retrieve | Canvus |
| profile | supported_views["profile"] | Profile |
| canvas | supported_views["canvas"] | Profile |
To use the code in this section, make sure you include <Require feature="views"> in the ModulePrefs section of your application.
If you want to provide links between views (ie. link from the Profile view to the Canvas page), gadgets.views.requestNavigateTo is the method to use. All you need to do is pass in a View object returned from getSupportedViews which is described in Available Views in itimes above. The following code sample demonstrates this method:
An alternative is to create a new View object manually and use it to initiate navigation. The following code sample shows how to create a new gadgets.views.View object and pass it to the gadgets.views.requestNavigateTo() method:
An alternative is to create a new View object manually and use it to initiate navigation. The following code sample shows how to create a new gadgets.views.View object and pass it to the gadgets.views.requestNavigateTo() method:
To use the code in this section, make sure you include <Require feature="views"> in the ModulePrefs section of your application.
If you are using gadgets.views.requestNavigateTo, you may supply an optional parameter containing data to be passed to the new page.
The following code passes two variables: foo and bar to the canvas view of the current application:
An alternative is to create a new View object manually and use it to initiate navigation. The following code sample shows how to create a new gadgets.views.View object and pass it to the gadgets.views.requestNavigateTo() method:
An alternative is to create a new View object manually and use it to initiate navigation. The following code sample shows how to create a new gadgets.views.View object and pass it to the gadgets.views.requestNavigateTo() method:
To use the code in this section, make sure you include <Require feature="views"> in the ModulePrefs section of your application.
If you are using gadgets.views.requestNavigateTo, you may supply an optional parameter containing data to be passed to the new page.
The following code passes two variables: foo and bar to the canvas view of the current application:
In the Canvas view, check for these values with the following code:
Caution: In itimes, the Profile view may contain more than one application, which makes targeting data to a specific application impossible. Therefore, you can only pass data in this manner to the Canvas view of an application. Data passed to the Profile view
To use the code in this section, make sure you include <Require feature="views"/> in the ModulePrefs section of your application.
There may be cases where you need to pass data to your application's Canvas view from the query string. itimes allows for a special URL parameter named "appParams" that a user can use to pass data to his / her application. For example, going to the URL
(where ##### is your application's ID number) will forward a parameter named hello with a value of hi to your application. You can retrieve this parameter in the following manner:
%7B%20%22hello%22%20%3A%20%22hi%22%20%7D represents a URL-encoded version of a JSON encoded object, which is the format itimes expects the appParams value to be in. If you wish to pass data to your applications, you will need to define a JavaScript object and assign an encoded, serialized version of this object to the appParams URL argument.
For example, to pass variables foo with value 12345 and bar with value "Bar value", first place these values in an object:
To serialize this object into a JSON string, you can use the gadgets.json.stringify function, or any other JSON library.
json_data will contain the value {"foo":12345,"bar":"Bar value"} after running the previous two code snippets. To escape this value for use in a query string, use the encodeURIComponent JavaScript function:
url_data will contain the value
%7B%22foo%22%3A12345%2C%22bar%22%3A%22Bar%20value%22%7D after executing the previous snippets. You may now use this value in the appParams query string parameter to pass your data to your application:
This approach is more difficult to use than the requestNavigateTo approach outlined in Passing data to your application through requestNavigateTo(), but the links one generates in this manner can be displayed on external websites or in activity stream entries.
To use the code in this section, make sure you include <Require feature="views"/> in the ModulePrefs section of your application
A user may combine some of these techniques to create URLs that can link to different pages in his / her application. If a user wishes to provide a link to an 'About' page in their application, he / she needs to dynamically generate a link like
where XXXXXXXX is the application's ID and YYYYYYYY is the itimes UID of the person one wishes to link to . URLs in this format can be constructed in the following manner:
You can print these links in a user's activity stream or even on an external website.
If you want to redirect a user to the 'About' page without necessarily generating a URL, call gadgets.views.requestNavigateTo with extra parameter data:
In your application, switch on the value of the page parameter to choose which page to render:
This code will work regardless of the method a user chooses to pass the page parameter to their application.
For an application to access user profile data, the user must have granted access to the app by choosing to install it on his / her own profile.
The data that will be made available to applications will only be data that users have marked as being visible to everyone. Data that is restricted to friends or friends of friends will not be available to applications.
This section lists all the profile fields available through OpenSocial, and itimes' access policy for each. The following policy labels are used:
| Available | Data will be made available to the application if the user has the application installed AND has chosen the "Share with Everyone" privacy setting for the field in question. |
| Not Applicable (N/A) | These fields are not included in itimes and hence are not available to applications. |
| Not Yet Implemented | These fields may be available to apps in the future. |
| Personally Identifiable Informatio | These fields are not available to applications. |
| itimes field | OpenSocial field | itimes access policy |
| First name | NAME (GIVEN_NAME) | Available |
| Last name | NAME (FAMILY_NAME) | Available |
| Profile URL | PROFILE_URL | Available |
| Thumbnail URL | THUMBNAIL_URL | Available |
| Gender | GENDER | Available |
| Relationship status | RELATIONSHIP_STATUS | Available |
| City, State, Country | CURRENT_LOCATION, ADDRESSES | Available |
| Languages I know | LANGUAGES_SPOKEN | Available |
| High school | SCHOOLS | Available |
| College / university | SCHOOLS | Available |
| Interested in | LOOKING_FOR | Available |
| Pets | PETS | Available |
| Webpage | URLS | Available |
| About me | ABOUT_ME | Available |
| Books | BOOKS | Available |
| Music | MUSIC | Available |
| TV Shows | TV_SHOWS | Available |
| Movies | MOVIES | Available |
| Cuisines | FOOD | Available |
| Primary email | EMAILS | Available |
| Secondary emails | EMAILS | Available |
| Land line | PHONE_NUMBERS | Available |
| Cell phone | PHONE_NUMBERS | Available |
| Address | CURRENT_LOCATION, ADDRESSES | Available |
| City, State, Country | CURRENT_LOCATION, ADDRESSES | Available |
| High school | SCHOOLS | Available |
| College / university | SCHOOLS | Available |
| Major | N/A | N/A |
| Degree | N/A | N/A |
| Year | SCHOOLS (END_DATE) | Available |
| Status | STATUS | Available |
| Turn ons | TURN_ONS | Available |
| Turn offs | TURN_OFFS | Available |
itimes Developers guide.
Guidlines for OpenSocial.
Anatomy of an itimes application.