Data Request Types

A developer may want to request several types of data to help build his application base. For example, he might want the user’s profile information or a series of activities from the user’s friends, or he might want to simply make a remote data request for a raw JSON feed. Fortunately, OpenSocial defines a series of data request types that allows developers to easily load social, private, or public data sources for use within their applications.

Container requests with <os:DataRequest>

Within the OpenSocial social API server and core API server specifications (described in Chapter 5), there are several definitions for REST endpoints to collect data from the container. This data may be social in nature, such as a user’s profile or activity information (in the case of the social API server), or simply be container-specific data not tied to the user’s social information (as in the case of the core API server). The DataRequest tag provides a method for developers to collect this information easily, making it available within their program flow.

Much like with any other data pipelining feature, the developer must add the Require feature="opensocial-data" tag in the gadget XML file in order to use the DataRequest tag. Once the feature is available, pulling in the data source is a trivial matter of specifying the REST method that you would like to fetch and the parameters that should be sent to that endpoint:

<script type="text/os-data" xmlns:os=""> ...

Get Programming Social Applications now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.