OpenSocial OpenSocial and Gadgets Specification Group
<opensocial-specification-v0_9> April 15, 2009

OpenSocial Specification v0.9
opensocial-specification-v0_9


Table of Contents


1. Notation and Conventions

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC2119 [RFC2119]. Domain name examples use RFC2606 [RFC2606].


2. Overview

OpenSocial is a set of APIs for building social applications that run on the web. OpenSocial's goal is to make more apps available to more users, by providing a common API that can be used in many different contexts. Developers can create applications, using standard JavaScript and HTML, that run on social websites that have implemented the OpenSocial APIs. These websites, known as OpenSocial containers, allow developers to access their social information; in return they receive a large suite of applications for their users.

The OpenSocial APIs expose methods for accessing information about people, their friends, and their data, within the context of a container. This means that when running an application on Orkut, you'll be interacting with your Orkut friends, while running the same application on MySpace lets you interact with your MySpace friends. For more information on the types of information exposed by the OpenSocial API, see the Key concepts section.

This document describes the concepts and principles behind the OpenSocial JavaScript APIs. It is a complement to the JavaScript API Reference, which covers the details of specific methods and parameters. This document does not describe any particular implementation of the API.


3. Compliance

So what does it mean to be an OpenSocial container? In a practical sense, it means that a site can run any application built on the OpenSocial APIs. This implies a number of things:

  1. The container must implement all methods in Section 5.

    The OpenSocial JavaScript APIs include the methods in the Lightweight JavaScript APIs (Section 5.2) as well as methods from Section 5. Methods may return the error code opensocial.ResponseItem.NOT_IMPLEMENTED for a specific method if the container does not support a specific request.

  2. The container must only use the specified extensibility mechanisms for any container-specific extensions.

    Extra person, activity or other object fields should be defined in an enum under the container's namespace, and the environment should allow applications to discover these fields. For example, if the field orkut.PersonField.SPECIAL_FIELD is defined as "orkut.specialPersonField", then opensocial.getEnvironment().supportsField("person", "orkut.specialPersonField") and opensocial.getEnvironment().supportsField(opensocial.Environment.ObjectType.PERSON, orkut.PersonField.SPECIAL_FIELD) should both return the same value.

    Any extra data request types should be available with a namespaced call like myspace.newFetchAlbumRequest. The gadget would then use batchRequest.add(myspace.newFetchAlbumRequest(...)).

    Any extra objects may be added to the container's own namespace. These objects can be returned from person.getField or other similar requests.

  3. The container must satisfy the [Gadgets API Specification].

    In short, this requires handling three types of requests: the Gadget Rendering Request, the Gadget Metadata Request, and the JavaScript Request.

    For the JavaScript APIs, you must implement the gadgets core JavaScript API [Gadgets API Specification], as per the documentation.

  4. The container must support the [RESTful Protocol Specification].

    Containers must provide JSON, XML, and AtomPub representations of data. OpenSocial uses HTTP GET to retrieve, PUT to update in place, POST to create new, and DELETE to remove. POST operates on collections and creates new activities, persons, or app data within those collections.

  5. The container may support the [RPC Protocol Specification].

    Containers may optionally provide an RPC alternative to the RESTful protocol. This specification supports the same data and operations as the RESTful protocol, but in a form more suited to JSON.

  6. The container MUST support the OpenSocial Markup Language.

    The OpenSocial Markup language consists of [OpenSocial Templating] and [OpenSocial Markup Language Tags].

  7. The container MUST support Data Pipelining

    [OpenSocial Data Pipelining] is a declarative syntax for defining the data you want the container to provide to you for processing.

  8. Containers that support the creation of and updating AppData SHOULD provide at least 10KB of space per user per application for storage.

4. Background

The rest of this document provides background information only and is not part of the OpenSocial specification. OpenSocial container compliance is determined solely based on Section 3, Compliance.

4.1 Key Concepts

Social applications revolve around people and their relationships. OpenSocial provides a standard way for websites to expose their social graph and more. Seeing the activities of other people helps you stay up to date with your friends, and allows everything from resumes to videos to spread virally through the graph. OpenSocial also provides a way for application data to persist on a social networking site, as well as specifying the different ways that an application can be viewed within an OpenSocial container. Finally, OpenSocial defines an API through which users of web services, mobile devices, and desktop applications may interact with social data.

4.1.1 People

It's people! Social graphs are made out of people! People are a fundamental part of social networking software and the OpenSocial API. The Person object provides access to a user's information. Part of this information is stored in the user's profile and, depending on the site, can include anything from "favorite TV shows" to "5 things you'll find in my bedroom." The other important user information is the set of connections they have in the social graph and this is covered in the Relationships section.

There are two Person objects that can be requested directly: the VIEWER and the OWNER. To understand the distinction, imagine you're checking out a coworker's profile on Orkut. In this case, you are the VIEWER and your coworker is the OWNER. It's also common to view your own profile, in which case you are both the VIEWER and the OWNER, and some applications may choose to handle this case differently. OpenSocial also provides for the case of anonymous viewing, where the gadget will not be able to access the VIEWER's information.

The API Reference contains more detailed information about the Person class (Section 5.3.51).

4.1.1.1 A note about user IDs

One of the pieces of data that is always returned with a Person object is the user's ID. The user ID must only contain alphanumeric (A-Za-z0-9) characters, underscore(_), dot(.) or dash(-), and must uniquely identify the user in a container. This standardization is intended to allow for prefixing IDs with a domain name and separator to create globally unique IDs (e.g. "orkut.com:34KJDCSKJN2HHF0DW20394"). Note that there will likely be a size limit placed on user IDs to help manage storing IDs in a database.

4.1.2 Relationships

The ability to create relationships is what turns a multi-user application into social software. Being able to share information and interact with friends changes the dynamic of user experience: you're engaging with people, not software.

There are two representations of sets of people available to OpenSocial: VIEWER_FRIENDS and OWNER_FRIENDS. In the case where you're checking out a coworker's profile, requesting VIEWER_FRIENDS will return the set of users that are friends with you, while requesting OWNER_FRIENDS will return the set of users that are friends with your coworker. Logically, if you're viewing your own profile, VIEWER_FRIENDS and OWNER_FRIENDS will be the same set of users. Also, if the container support anonymous profile browsing, then the application won't be able to access the set of VIEWER_FRIENDS.

Note that OpenSocial makes no assumptions about the relationship between VIEWER and OWNER. The VIEWER and OWNER could be friends, but if you're looking at a stranger's profile, there's no relationship between you, the VIEWER, and them, the OWNER.

When an application wants to interact with or display data for "friends of friends", the OpenSocial specification supports extending a query for VIEWER_FRIENDS or OWNER_FRIENDS by a NETWORK_DISTANCE parameter. Containers can optionally support "friends of friends" queries, "friends of friends of friends" queries, and so on.

4.1.3 Activities

Since we can't be online all the time, it helps to have a record of what our friends have been up to, so long as your friends want to share that record. Seeing how other people are interacting with a social application also allows you to learn new features and uses of the application, so activity streams are one of the major drivers for organic growth of applications.

OpenSocial exposes activity streams, which are a collection of actions a user has taken in the context of a given container. These activities can include interaction with the container itself, such as updating your profile or installing a new gadget, or interaction with an OpenSocial application, such as sending your friend a virtual gift or setting a new high score in a game.

Activity templates allow application developers to define messages with placeholders for pieces of applicaton or user data. This separation of data and presentation allows multiple activities to be combined into activity summaries: consolidated bundles of activities that let users know what their friends are up to without having to wade through a flood of messages.

The API Reference contains more detailed information about the Activity class (Section 5.3.2).

4.1.4 Messaging

Almost all Social networks offer a way of reading, posting, and deleting messages between users in the network. Opensocial defines a number message types including public messages (such as profile comments), private messages (messages restricted to certain individuals and groups. More information about messages is in the Message class (Section 5.3.39). Messages are grouped into MessageCollections that include a unique id, name and sizing on the number of messages.

A standard set of operations via REST and JavaScript is available to read, write and delete messages, message collections and comments.

4.1.5 Persistence

Applications can provide a richer user experience if they can save their state between sessions. OpenSocial defines a data store that applications can use to read and write user-specific data. This data store can be read by anyone who can see the gadget, but only the VIEWER's user-scoped data is writable.

Clearly this free data store could be abused, so containers may implement quotas or rate limits to preserve their disk space. However, OpenSocial does not currently define these policies.

The keys that developers specify to index this data must only contain alphanumeric (A-Za-z0-9) characters, underscore(_), dot(.) or dash(-).

Since application data is often created based on user inputs, OpenSocial containers perform automatic HTML escaping of all application data. However, developers have the option of turning off this escaping by setting the escapeType parameter on newFetchPersonAppData and getField calls.

4.1.6 Views

Containers can support several different locations where gadgets may be rendered. Such locations are formally called views (formerly Surfaces in earlier versions of the API). All gadgets (not just OpenSocial applications) have become view-aware. A gadget can ask which view it is currently being rendered on, as well as what views the container supports.

Containers may define their own views, but the specification defines the following standard views in the gadgets.views.View Type object:

In addition to requesting data about the current view, gadgets may also request that the container navigate the user to another view. Imagine a news gadget that normally runs in a small profile view that changes to a full canvas view if the user clicks on a headline to get more information. Gadgets can choose the best rendering context for their current state.

When navigating to another view, a gadget may also request a change in OWNER. For example, imagine an application that places a survey on the user's profile view. This application may want to provide links to the user's friends' profiles, so that the user can see which surveys his or her friends are currently displaying.

Containers can also specify a template that applications can use to generate URLs to a specific application canvas and user. Such URLs can be shared via activity updates and printed on external websites, so linking to applications from external sources is easy.

4.1.7 Lifecycle Events

Certain types of events may occur during the lifecycle of a gadget that are desirable yet difficult for developers to track. Such events include installs, uninstalls, rate limiting, directory listing changes, and blacklist/whitelist notifications. The gadget specification allows developers to specify URLs that the container will POST event data to when certain events are triggered.

By tracking the data POSTed to the specified URL, gadget developers can accurately track number of installs, remove database entries upon uninstall, and get automatic notifications if their gadget exceeds a quota or is marked as spam by the container. A container may optionally support sending lifecycle events to an application developer's site by sending relevant query parameters to a URL endpoint. To receive these events, you can place one or more Link tags in your application's XML. Each Link tag has a rel and href attribute. The href attribute denotes the endpoint where event pings are sent. If the rel attribute is "opensocialevent", then all events are sent to that endpoint. If the rel attribute matches "opensocialevent.TYPE", then events of TYPE are sent to that endpoint. An optional method attribute can be set to POST or GET to specify how the request should be sent. The default is GET.

Here are some examples:

<Link rel="event" href="http://www.example.com/pingme" method="POST/>
<Link rel="event.addapp" href="http://www.example.com/add" />
<Link rel="event.removeapp" href="http://www.example.com/remove" />

The following eventtype query parameter will always be sent to the endpoint. eventtype specifies the event type.

Note that these requests will always be signed by the container, and your server should check that the signature is valid by using the OAuth algorithm for signature verification.

Most events will have information about one or more OpenSocial ID values. These id values are passed as one or more id attributes. Note that a single ping may aggregate a number of events by specifying many id values.

The following event types are defined. Container custom events should be designated with a domainname prefix to avoid namespace collisions.

EventDescription
addappid attribute identifies users who have installed the app. from attribute designates how the user added this app. Values are "invite", "gallery", "external". Optional.
removeappid attribute identifies users who have removed the app.
appaction attribute designates the action performed on the app. Values are "enabled", "disabled", and "approved". reason attribute identifies the reason for the action. Values are "policy", "quota", "maintenance". Optional.
titleid attribute indicates users who have been invited. from_id attribute indicates the user who sent the invitation.

4.1.8 RESTful API

When is an OpenSocial application not just a gadget? When it has a backend server that talks directly to the container, of course! The [RESTful Protocol Specification] defines a way for servers, mobile devices, and desktop computers to interact with an OpenSocial container without requiring JavaScript or direct user interaction. Applications can update activities, send messages, and fetch OpenSocial data in the background using either an AtomPub, XML, or JSON REST service.

4.2 API Patterns

This section describes several common patterns in the OpenSocial API. Understanding these concepts should help you wade through the API Reference.

4.2.1 Making Request

The OpenSocial API queries the container asynchronously for most of its calls, which is why most OpenSocial methods don't directly return data, but rather allow you to specify a callback that will be executed when the server's response is ready. Of course, making lots of asynchronous requests isn't always ideal, so the API allows for batch requests to allow developers to ask for many pieces of information at once. A developer can create an opensocial.DataRequest and add several individual request objects to it. Upon receiving the DataRequest, the container can process each request optimally and return the results of each operation as a batched result object. Containers must preserve the semantics of executing requests in serial order, though. A request that contains a write and then a read must return the newly written data, while a request that contains a read and then a write must return the data that was present before the write took place.

4.2.2 Capabilities Discovery

The gadgets and OpenSocial specifications determine the common APIs that all containers will support, but there are cases where a certain method or a profile field will be offered as an extension in some containers. To help developers write gadgets that can take advantage of these extensions, yet degrade gracefully in their absence, these APIs include gadgets.util.hasFeature and opensocial.Environment.supportsField methods to query the container at runtime and determine which features are available.

Of course, OpenSocial has compliance rules (Section 3) that must be adhered to by containers wishing to extend the API.

4.2.3 Action Requests and Permissions

There are cases where a gadget may wish to perform an action that needs approval by the user or mediation by the container. OpenSocial supports "request" features that allow the container to decide how to handle the interaction with the user. Functions like opensocial.requestCreateActivity, and opensocial.requestPermission allow the container to inject its own policy decisions into the gadget execution flow and notify the gadget of the result. Under this specification, it is equally valid for a container to defer to the user, always approve, always deny, or use any other method to determine responses to request calls. Additionally, this allows the container to enforce UI flows in a safe and integrated way.

4.2.4 Profile Fields

User profiles are different from container to container. On consumer-oriented containers, applications may be interested in a user's idea of a perfect first date, but this may not be appropriate for business-oriented containers. This is why OpenSocial allows containers to extend Person objects with arbitrary fields: to match the feel and uses of each container site. Profile fields are therefore obtained through Person.getField calls rather than having hardcoded getters and setters for each property. See the Compliance and Capabilities discovery sections for more information about how containers can add additional data to the API, and how applications can determine which fields are available for use.

4.2.5 Fetching Content From Remote Servers

Gadgets can use the gadgets.io.makeRequest method to pull HTML, JSON, XML, and ATOM data from remote servers.

The gadgets.io.makeRequest call can also be used to pass data from gadgets back to application servers in a way that cannot be spoofed. The container is expected to mediate communications from the gadget to the application server (e.g. ilike.com). Therefore trusted content fetching has two main steps: [1] the gadget contacts the container, and [2] the container contacts the application server.

  1. When the gadget contacts the container, the container needs to be able to validate any parameters it knows about: the viewer id, the owner id (if known), and the application id. Validating these parameters is an implementation detail that may vary between containers. For example, Orkut uses an encrypted token passed in the document fragment of the gadget URL.
  2. When the container contacts the app server, the app server needs to be able to validate that the parameters really came from the container (and were not forged by some other entity). OpenSocial uses OAuth's parameter signing algorithm Note that most of the functionality in the OAuth spec, including token exchange, is not required; OpenSocial only plans to use the parameter signing piece of the spec (including timestamp and nonce). OpenSocial permits the HMAC-SHA1 method (except that the key is a shared secret between container and app, not a concatenation of tokens as specified in section 9.2 of the OAuth spec) and the RSA-SHA1 method. HMAC-SHA1 is faster and easier to implement, but it requires more coordination than RSA-SHA1.

If a user needs to fetch data from a protected resource, the makeRequest call supports full OAuth authentication [OAuth Core 1.0] via a container proxy. Gadgets can now access protected web services without requiring the user to share their password with the gadget, allowing for sophisticated and secure integration with web APIs that support OAuth.

4.2.6 Caching

When gadgets call makeRequest, the calls may be cached. This is great for reducing the load that your servers have to be able to handle, since OpenSocial applications may have millions of users, each requesting data from your server. However, this caching of makeRequest calls can wind up displaying old data to users if the content returned by your server changes often.

If you expect the content at the URL you are fetching to change frequently, you may want to work around the automatic caching with a more finely grained method. You can define a refreshInterval parameter, which should be specified as the number of seconds that should elapse before the makeRequest call requests content from your servers again. For example, specifying 10 will mean that the container would only query the supplied URL once every 10 seconds, no matter how many people are using the application. Specifying 0 will query the server each time the function is called, effectively bypassing the cached version.


5. API Reference

5.1 Using the API Reference

The JavaScript API reference is a complete listing of the methods and fields that OpenSocial requires, but some conventions are not immediately understandable. This section will explain some of the assumptions used in generating the API reference.

5.1.1 Virtual Typing

JavaScript is not strongly typed, but in order to make the developer experience consistent, the APIs are defined as if JavaScript supported strongly typed data. Cases where a parameter or return value are defined as a certain type in the documentation indicate that this is the only type that can be provided or accepted for OpenSocial compatibility. Any exceptions to this rule will be directly documented in the reference.

As an example, the getErrorCode method is defined in the JavaScript API reference as returning a value of the type opensocial.ResponseItem.Error, although in practice this value will be a normal JavaScript string. However, developers can be assured that in a compliant container, the string returned is one of the opensocial.ResponseItem.Error fields.

Enumerations figure heavily into the OpenSocial API. Developers are permitted to reference an enum or use the enum's value directly. To avoid collisions related to extensibility, containers must ensure that the names and values for an enum match the ones defined in the spec and that custom values are namespaced appropriately. For example, an Orkut custom field named MY_PERSON_FIELD could have a name of Orkut.PersonField.MY_PERSON_FIELD and a value of "Orkut.myPersonField". See the Compliance (Section 3) and Capabilities discovery (Section 4.2.2) sections for more information.

5.1.2 Parameter Maps

Many of the OpenSocial methods have a large number of optional parameters. JavaScript's lack of strong typing makes overloading difficult at best, and having functions with a large amount of parameters can be difficult to manage (especially for developers not using a nice IDE). OpenSocial uses the "object bag" approach to optional parameters: many methods take an additional opt_params parameter that takes the form of a map of parameter names to their corresponding values.

For each method which uses an opt_params map the spec defines all of the valid fields that will be read out of the map by the container. These fields have defined types as discussed in the Virtual typing section. If a developer adds an invalid value for a field in the map the container should return the BAD_REQUEST error code.

5.2 Lightweight JavaScript API

5.2.1 Summary

The Lightweight Javascript API, or OS Lite, is more natural to JavaScript developers and more succinct for creating OpenSocial gadgets than the existing JS APIs. It relies on the existing JSON-RPC protocol handlers, and is marked by the use of simple JSON objects as input and output. Note: this implementation follows the JSON-RPC spec 1:1, but could also be implemented over REST.

For compatibility purposes, the existing JS APIs are still in place, and we may consider deprecating them in the 1.0 timeframe if developers move to these new APIs.

5.2.1.1 Highlights

5.2.1.2 Examples

A Person request, the most basic example:

osapi.people.getViewer().execute(function(result) {
  if (!result.error) {
    alert('Your name is ' + result.name + '!');
  }
});

A Person request with a JSON request parameter object specifying which fields to retrieve:

osapi.people.getViewer({fields: ['name', 'birthday']}).execute(function(result) {
  if (!result.error) {
    alert('Your name is ' + result.name + '!');
    alert('Your birthday is ' + result.birthday + '!');
  }
});

Batch request to retrieve a Person and Activities:

var batch = osapi.newBatch().
    add("viewer", osapi.people.getViewer()).
    add('activities', osapi.activities.get({ userId : '@viewer', groupId : '@self'})).
batch.execute(function(result) {
  if (!result.error) {
    alert('Hi, ' + result.viewer.name + '!');
    alert('You have ' + result.activities.length + ' activities.');
  }
});

5.2.2 Detailed Description

A container MUST emit the OS Lite JavaScript libraries and data files required by the libraries if an application includes <Require feature="osapi"/> in the ModulePrefs section of the gadget XML file. The container SHOULD emit the OS Lite JavaScript libraries and data files required by the libraries if an application optionally requests the feature by including <Optional feature="osapi"/> in the ModulePrefs of the gadget XML file.

The services available on the client are determined by the server from which the JavaScript is delivered. The server SHOULD generate service methods for all available services. Developers wanting to write gadgets safely can test for the existence of a service and method before making their call.

Example:

if (osapi.people && osapi.people.getViewer) {
  osapi.people.getViewer().execute(function(result) {
    if (!result.error) {
      alert('Your name is ' + result.name + '!');
    }
  });
}

5.2.2.1 Service Objects

5.2.2.1.1 osapi.people

Service object with functions that map to the JSON-RPC people endpoint.

5.2.2.1.1.1 Method Details
5.2.2.1.1.1.1 get

<static> Type: { osapi.Request (Section 5.2.2.2.1) } osapi.people.get(params)

Description: Builds a request to retrieve information from the JSON-RPC People service. When no parameter is specified, the server defaults, { userId : @me, groupId : @self}, will be used and the viewer's information will be returned.

Parameters:

NameTypeDescription
params{
AuthToken auth = HttpRequest.Authorization,
String or Array.<String> userId = "@me",
String groupId = "@self",
Array.<String> fields,
int count,
int startIndex,
int startPage
}
An optional JSON object containing request parameters. See the get operation of the JSON-RPC people endpoint for more details.

Returns:

TypeDescription
osapi.Request (Section 5.2.2.2.1) A request to retrieve information from the JSON-RPC People service.
5.2.2.1.1.1.2 getViewer

<static> Type: { osapi.Request (Section 5.2.2.2.1) } osapi.people.getViewer(params)

Description: A convenience over osapi.people.get() that builds a request to retrieve the viewer, as specified in the security token, from the people JSON-RPC service.

Parameters:

NameTypeDescription
params{
AuthToken auth = HttpRequest.Authorization,
Array.<String> fields,
}
An optional JSON object containing request parameters. See the get operation of the JSON-RPC people endpoint for more details.

Returns:

TypeDescription
osapi.Request (Section 5.2.2.2.1) A request to retrieve information from the JSON-RPC People service.
5.2.2.1.1.1.3 getViewerFriends

<static> Type: { osapi.Request (Section 5.2.2.2.1) } osapi.people.getViewerFriends(params)

Description: A convenience over osapi.people.get() that builds a request to retrieve the viewer's friends, as specified in the security token, from the people JSON-RPC service.

Parameters:

NameTypeDescription
params{
AuthToken auth = HttpRequest.Authorization,
Array.<String> fields,
int count,
int startIndex,
int startPage
}
An optional JSON object containing request parameters. See the get operation of the JSON-RPC people endpoint for more details.

Returns:

TypeDescription
osapi.Request (Section 5.2.2.2.1) A request to retrieve information from the JSON-RPC People service.
5.2.2.1.1.1.4 getOwner

<static> Type: { osapi.Request (Section 5.2.2.2.1) } osapi.people.get(params)

Description: A convenience over osapi.people.get() that builds a request to retrieve the owner, as specified in the security token, from the people JSON-RPC service.

Parameters:

NameTypeDescription
params{
AuthToken auth = HttpRequest.Authorization,
Array.<String> fields,
}
An optional JSON object containing request parameters. See the get operation of the JSON-RPC people endpoint for more details.

Returns:

TypeDescription
osapi.Request (Section 5.2.2.2.1) A request to retrieve information from the JSON-RPC People service.
5.2.2.1.1.1.5 getOwnerFriends

<static> Type: { osapi.Request (Section 5.2.2.2.1) } osapi.people.get(params)

Description: A convenience over osapi.people.get() that builds a request to retrieve the owner's friends, as specified in the security token, from the people JSON-RPC service.

Parameters:

NameTypeDescription
params{
AuthToken auth = HttpRequest.Authorization,
Array.<String> fields,
int count,
int startIndex,
int startPage
}
An optional JSON object containing request parameters. See the get operation of the JSON-RPC people endpoint for more details.

Returns:

TypeDescription
osapi.Request (Section 5.2.2.2.1) A request to retrieve information from the JSON-RPC People service.
5.2.2.1.1.2 Examples

A simple example to request the owner's friends:

osapi.people.get({userId: '@owner', groupId: '@friends'}).execute(function(ownerFriends) {
  if (!result.error) {
    alert('You have ' + ownerFriends.length + ' friends');
  }
});

An example that illustrates all available request parameters:

var params = {
    auth: {"default" : null, "type" : "AuthToken"},
    userId: "@owner", 
    groupId: "@friends",
    fields: "@all",
    count: 10,
    startIndex: 0, 
    startPage: 0
};
osapi.people.get(params).execute(function(ownerFriends) {
  if (!result.error) {
    alert('You have ' + ownerFriends.length + ' friends');
  }
});
5.2.2.1.2 osapi.activities

Service object with functions that map to the JSON-RPC activities endpoint.

5.2.2.1.2.1 Method Details
5.2.2.1.2.1.1 get

<static> Type: { osapi.Request (Section 5.2.2.2.1) } osapi.activities.get(params)

Description: Builds a request to retrieve activities from the Activities JSON-RPC service.

Parameters:

NameTypeDescription
params{
AuthToken auth = HttpRequest.Authorization,
String or Array.<String> userId = "@me",
String groupId = "@self",
String appId = auth.AppId,
Array.<String> activityIds = [],
Array.<String> fields,
int count,
int startIndex,
int startPage
}
An optional JSON object containing request parameters. See the get operation of the JSON-RPC Activities service for more details.

Returns:

TypeDescription
osapi.Request (Section 5.2.2.2.1) A request to retrieve information from the JSON-RPC Activities service.
5.2.2.1.2.1.2 create

<static> Type: { osapi.Request (Section 5.2.2.2.1) } osapi.activities.get(params)

Description: Builds a request to create an activity using the Activities JSON-RPC service.

Parameters:

NameTypeDescription
params{
AuthToken auth = HttpRequest.Authorization,
String or Array.<String> userId = "@me",
String groupId = "@self",
String appId = auth.AppId,
opensocial.Activity activity,
}
An optional JSON object containing request parameters. See the create operation of the JSON-RPC Activities service for more details.

Returns:

TypeDescription
osapi.Request (Section 5.2.2.2.1) A request to retrieve information from the JSON-RPC Activities service.
5.2.2.1.2.2 Examples

A simple example to retrieve the activities of the viewer's friends:

osapi.activities.get({userId: '@viewer', groupId: '@friends', count: 20}).execute(myCallback);

An example illustrating all available request parameters for osapi.activites.get():

var params = {
    auth: {"default" : null, "type" : "AuthToken"},
    userId: "@me", 
    groupId: "@self",
    appId: "XXXXXXX",
    activityIds = ["YYYYYYY", "ZZZZZZZ"],
    fields: "@all",
    count: 10,
    startIndex: 0, 
    startPage: 0
};
osapi.activities.get(params).execute(myCallback);

A simple example to create an activity for the viewer:

osapi.activities.create({userId: '@viewer', activity: {title: 'Hello!', url: 'http://mysite.com'}}).execute(myCallback);

An example illustrating all available request parameters for osapi.activites.create():

var params = {
    auth: {"default" : null, "type" : "AuthToken"},
    userId: "@viewer", 
    groupId: "@self",
    appId: "XXXXXXX",
    activity: {title: 'Hello!', url: 'http://mysite.com'}
};
osapi.activities.create(params).execute(myCallback);
5.2.2.1.3 osapi.appdata

Service object with functions that map to the JSON-RPC app data endpoint.

5.2.2.1.3.1 Method Details
5.2.2.1.3.1.1 get

<static> Type: { osapi.Request (Section 5.2.2.2.1) } osapi.appdata.get(params)

Description: Builds a request to retrieve data from the AppData JSON-RPC service.

Parameters:

NameTypeDescription
params{
AuthToken auth = HttpRequest.Authorization,
String or Array.<String> userId = "@me",
String groupId = "@self",
String appId = auth.AppId,
Array.<String> keys,
}
An optional JSON object containing request parameters. See the get operation of the JSON-RPC AppData service for more details.

Returns:

TypeDescription
osapi.Request (Section 5.2.2.2.1) A request to retrieve information from the JSON-RPC AppData service.
5.2.2.1.3.1.2 update

<static> Type: { osapi.Request (Section 5.2.2.2.1) } osapi.appdata.update(params)

Description: Builds a request to create or update data from the AppData JSON-RPC service.

Parameters:

NameTypeDescription
params{
AuthToken auth = HttpRequest.Authorization,
String or Array.<String> userId = "@me",
String groupId = "@self",
String appId = auth.AppId,
Map.<String, String> data,
}
An optional JSON object containing request parameters. See the update operation of the JSON-RPC AppData service for more details.

Returns:

TypeDescription
osapi.Request (Section 5.2.2.2.1) A request to retrieve information from the JSON-RPC AppData service.
5.2.2.1.3.1.3 delete

<static> Type: { osapi.Request (Section 5.2.2.2.1) } osapi.appdata.delete(params)

Description: Builds a request to delete data from the AppData JSON-RPC service.

Parameters:

NameTypeDescription
params{
AuthToken auth = HttpRequest.Authorization,
String or Array.<String> userId = "@me",
String groupId = "@self",
String appId = auth.AppId,
Array.<String> keys,
}
An optional JSON object containing request parameters. See the delete operation of the JSON-RPC AppData service for more details.

Returns:

TypeDescription
osapi.Request (Section 5.2.2.2.1) A request to retrieve information from the JSON-RPC AppData service.
5.2.2.1.3.2 Examples

A simple example to retrieve, update, and delete a piece of app data:

osapi.appdata.get({userId: '@viewer', groupId: '@friends', keys: ['gifts']}).execute(myGetCallback);
osapi.appdata.update({userId: '@viewer', data: {gifts: 'a crazed monkey'}}).execute(myUpdateCallback);
osapi.appdata.delete({keys: ['gifts']}).execute(myDeleteCallback)

An example illustrating all available request parameters for osapi.appdata.get():

var getParams = {
    auth: {"default" : null, "type" : "AuthToken"},
    userId: "@viewer", 
    groupId: "@friends",
    appId: "XXXXXXX",
    keys: ['gifts', 'wishlist']
};
osapi.appdata.get(getParams).execute(myGetCallback);

An example illustrating all available request parameters for osapi.appdata.update():

var updateParams = {
    auth: {"default" : null, "type" : "AuthToken"},
    userId: "@viewer", 
    groupId: "@friends",
    appId: "XXXXXXX",
    data: {gifts: 'a crazed monkey', wishlist: 'a banana peel'}
};
osapi.appdata.update(updateParams).execute(myUpdateCallback);

An example illustrating all available request parameters for osapi.appdata.delete():

var deleteParams = {
    auth: {"default" : null, "type" : "AuthToken"},
    userId: "@viewer", 
    groupId: "@friends",
    appId: "XXXXXXX",
    keys: ['gifts', 'wishlist']
};
osapi.appdata.delete(deleteParams).execute(myDeleteCallback)
5.2.2.1.4 osapi.messages

Service object with functions that map to the JSON-RPC Messages endpoint.

5.2.2.1.4.1 Method Details
5.2.2.1.4.1.1 send

<static> Type: { osapi.Request (Section 5.2.2.2.1) } osapi.messages.send(params)

Description: Builds a request to send a message from the Messages JSON-RPC service.

Parameters:

NameTypeDescription
params{
AuthToken auth = HttpRequest.Authorization,
String userId = "@me",
opensocial.Message message
}
An optional JSON object containing request parameters. See the send operation of the JSON-RPC Messages service for more details.

Returns:

TypeDescription
osapi.Request (Section 5.2.2.2.1) A request to retrieve information from the JSON-RPC Messages service.
5.2.2.1.4.2 Examples

An example illustrating how to send a message using osapi.messages.send():

var params = {
    auth: {"default" : null, "type" : "AuthToken"},
    message: {
        "recipients" : ["example.org:AD38B3886625AAF", "example.org:997638BAA6F25AD"],
        "title" : "You have a message from Joe",
        "body" : "Some content",
        "type" : "EMAIL"
    },
};
osapi.appdata.delete(deleteParams).execute(myDeleteCallback)
5.2.2.1.5 osapi.http

Service object for making HTTP requests to third party servers. This is not a JSON-RPC endpoint, but a third party web service.

5.2.2.1.5.1 Method Details
5.2.2.1.5.1.1 head

<static> Type: { osapi.Request (Section 5.2.2.2.1) } osapi.http.head(params)

Description: Creates a HEAD request to an arbitrary URL.

Parameters:

NameTypeDescription
urlStringThe URL where the content is located
params{
Map.<String, Array.<String>> headers,
String format = "json",
int refreshInterval,
String authz = "none",
Boolean sign_viewer = true,
Boolean sign_owner = true,
String oauth_service_name = "",
String oauth_token_name = "",
String oauth_request_token,
String oauth_request_token_secret,
String oauth_use_token,
}
Takes an optional parameter that is a JSON object containing parameters and values similar to the attributes of the <os:HttpRequest> tag.

Returns:

TypeDescription
osapi.Request (Section 5.2.2.2.1) A request to retrieve information an arbitrary URL.
5.2.2.1.5.1.2 get

<static> Type: { osapi.Request (Section 5.2.2.2.1) } osapi.http.get(params)

Description: Creates a GET request to an arbitrary URL.

Parameters:

NameTypeDescription
urlStringThe URL where the content is located
params{
Map.<String, Array.<String>> headers,
String format = "json",
int refreshInterval,
String authz = "none",
Boolean sign_viewer = true,
Boolean sign_owner = true,
String oauth_service_name = "",
String oauth_token_name = "",
String oauth_request_token,
String oauth_request_token_secret,
String oauth_use_token,
}
Takes an optional parameter that is a JSON object containing parameters and values similar to the attributes of the <os:HttpRequest> tag.

Returns:

TypeDescription
osapi.Request (Section 5.2.2.2.1) A request to retrieve information an arbitrary URL.
5.2.2.1.5.1.3 put

<static> Type: { osapi.Request (Section 5.2.2.2.1) } osapi.http.put(params)

Description: Creates a PUT request to an arbitrary URL.

Parameters:

NameTypeDescription
urlStringThe URL where the content is located
params{
Map.<String, Array.<String>> headers,
String body,
String format = "json",
int refreshInterval,
String authz = "none",
Boolean sign_viewer = true,
Boolean sign_owner = true,
String oauth_service_name = "",
String oauth_token_name = "",
String oauth_request_token,
String oauth_request_token_secret,
String oauth_use_token,
}
Takes an optional parameter that is a JSON object containing parameters and values similar to the attributes of the <os:HttpRequest> tag.

Returns:

TypeDescription
osapi.Request (Section 5.2.2.2.1) A request to retrieve information an arbitrary URL.
5.2.2.1.5.1.4 post

<static> Type: { osapi.Request (Section 5.2.2.2.1) } osapi.http.post(params)

Description: Creates a POST request to an arbitrary URL.

Parameters:

NameTypeDescription
urlStringThe URL where the content is located
params{
Map.<String, Array.<String>> headers,
String body,
String format = "json",
int refreshInterval,
String authz = "none",
Boolean sign_viewer = true,
Boolean sign_owner = true,
String oauth_service_name = "",
String oauth_token_name = "",
String oauth_request_token,
String oauth_request_token_secret,
String oauth_use_token,
}
Takes an optional parameter that is a JSON object containing parameters and values similar to the attributes of the <os:HttpRequest> tag.

Returns:

TypeDescription
osapi.Request (Section 5.2.2.2.1) A request to retrieve information an arbitrary URL.
5.2.2.1.5.1.5 delete

<static> Type: { osapi.Request (Section 5.2.2.2.1) } osapi.http.delete(params)

Description: Creates a DELETE request to an arbitrary URL.

Parameters:

NameTypeDescription
urlStringThe URL where the content is located
params{
Map.<String, Array.<String>> headers,
String format = "json",
int refreshInterval,
String authz = "none",
Boolean sign_viewer = true,
Boolean sign_owner = true,
String oauth_service_name = "",
String oauth_token_name = "",
String oauth_request_token,
String oauth_request_token_secret,
String oauth_use_token,
}
Takes an optional parameter that is a JSON object containing parameters and values similar to the attributes of the <os:HttpRequest> tag.

Returns:

TypeDescription
osapi.Request (Section 5.2.2.2.1) A request to retrieve information an arbitrary URL.
5.2.2.1.5.2 Examples

Suppose a request to http://www.somephotosite.com/latest returns the following JSON:

{
  photos : [ "http://www.somephotosite.com/photos/1.jpg",
             "http://www.somephotosite.com/photos/2.jpg",
             "http://www.somephotosite.com/photos/3.jpg",
           ],
  lastUpdate : "Mon, 13 Apr 2009 23:17:04 GMT"
}

The data can be retrieved and accessed as follows:

osapi.http.get('http://www.somephotosite.com/latest').execute(function(result) {
  if (!result.error) {
    alert('There are ' + result.content.photos.length + ' new photos');
  }
});

An example illustrating some available request parameters:

var params = {
    'format': 'json',
    'headers': {'Content-Type': ['application/json;charset=utf-8'], "Accept-Language": ["en-us"]},
    'body': {'numResults': 100, theme: 'beach'},
    'authz': 'SIGNED',
};
osapi.http.post('http://www.somephotosite.com/prefs?uid=1234', params).execute(function(result) {
  if (!result.error) {
    alert('Request to update user preferences was successful');
  }
});

5.2.2.2 Service Requests

5.2.2.2.1 Single Request Objects

All methods of OS Lite service objects (e.g. osapi.people.get()) return a JavaScript object representing the request. These objects MUST support the following method(s):

5.2.2.2.1.1 Method Details
5.2.2.2.1.1.1 execute

<static> osapi.Request.execute(callback)

Description: Executes the service request. Takes a callback for response processing.

Parameters:

NameTypeDescription
callbackFunctionA callback function to handle the response.
5.2.2.2.1.2 Examples

A simple example to request the owner's friends:

          osapi.people.get({userId: '@owner', groupId: '@friends'}).execute(function(ownerFriends) {
            if (!result.error) {
              alert('You have ' + ownerFriends.length + ' friends');
            }
          });
5.2.2.2.2 Batch Request Objects

Service requests can be combined into a single batch request using the following methods:

5.2.2.2.2.1 Method Details
5.2.2.2.2.1.1 newBatch

<static> Type: { osapi.BatchRequest (Section 5.2.2.2.2) } osapi.newBatch()

Description: Creates a new batch request.

Returns:

TypeDescription
osapi.BatchRequest (Section 5.2.2.2.2) A new batch request.
5.2.2.2.2.1.2 add

<static> Type: { osapi.BatchRequest (Section 5.2.2.2.2) } osapi.add(key, request)

Description: Adds a service request to the batch associated with the specified key. A single batch request can contain both JSON-RPC calls (e.g. osapi.people.get()) and HTTP calls to third parties (e.g. osapi.http.get()).

Parameters:

NameTypeDescription
keyStringA key to access the result of the given request from the parameter sent to the callback function.
request osapi.Request (Section 5.2.2.2.1) A request to add to the batch.

Returns:

TypeDescription
osapi.BatchRequest (Section 5.2.2.2.2) A batch request containing the given request (and any previously added requests).
5.2.2.2.2.1.3 execute

<static> osapi.Request.execute(callback)

Description: Executes all of the requests in the batch. Takes a callback for response processing, which is passed a JSON object mapping each request key to a JSON response object.

Parameters:

NameTypeDescription
callbackFunctionA callback function to handle the response.
5.2.2.2.2.2 Examples

An example illustrating two requests batched together:

          var batch = osapi.newBatch().
             add("viewer", osapi.people.getViewer()).
             add('activities', osapi.activities.get({ userId : '@viewer', groupId : '@self'})).
          batch.execute(function(result) {
            if (!result.error) {
              alert('Hi, ' + result.viewer.name + '!');
              alert('You have ' + result.activities.length + ' activities.');
            }
          });

5.2.2.3 Error Handling

The error handling works exactly as it does for the JSON-RPC interface, since this api is based on that protocol. The JSON object returned reflects any errors that occurred in the request. This breaks down into 3 types of errors:

5.3 API Class Reference

5.3.1 opensocial

Namespace for top-level people functions.

5.3.1.1 Constructor

opensocial

5.3.1.2 Method Details

5.3.1.2.1 getEnvironment

<static> Type: { opensocial.Environment (Section 5.3.29) } opensocial.getEnvironment()

Description: Gets the current environment for this gadget. You can use the environment to make queries such as what profile fields and surfaces are supported by this container, what parameters were passed to the current gadget, and so on.

Returns:

TypeDescription
opensocial.Environment (Section 5.3.29) The current environment (Section 5.3.29)
5.3.1.2.2 hasPermission

<static> Type: {Boolean} opensocial.hasPermission(permission)

Description: Returns true if the current gadget has access to the specified permission. If the gadget calls opensocial.requestPermission and permissions are granted then this function must return true on all subsequent calls.

Parameters:

NameTypeDescription
permissionopensocial.PermissionThe permission (Section 5.3.50)

Returns:

TypeDescription
BooleanTrue if the gadget has access for the permission; false if it doesn't
5.3.1.2.3 invalidateCache

<static> opensocial.invalidateCache()

Description: Invalidates all resources cached for the current viewer.

5.3.1.2.4 newActivity

<static> Type: { opensocial.Activity (Section 5.3.2) } opensocial.newActivity(params)

Description: Creates an activity object, which represents an activity on the server.

See also: requestCreateActivity() (Section 5.3.1.2.11),

It is only required to set one of TITLE_ID or TITLE. In addition, if you are using any variables in your title or title template, you must set TEMPLATE_PARAMS.

Other possible fields to set are: URL, MEDIA_ITEMS, BODY_ID, BODY, EXTERNAL_ID, PRIORITY, STREAM_TITLE, STREAM_URL, STREAM_SOURCE_URL, and STREAM_FAVICON_URL.

Containers are only required to use TITLE_ID or TITLE, and may choose to ignore additional parameters.

See Field (Section 5.3.3) for more details.

Parameters:

NameTypeDescription
paramsMap.<opensocial.Activity.Field|Object>Parameters defining the activity

Returns:

TypeDescription
opensocial.Activity (Section 5.3.2) The new activity (Section 5.3.2) object
5.3.1.2.5 newAlbum

<static> Type: { opensocial.MediaItem (Section 5.3.36) } opensocial.newAlbum(opt_params)

Description: Creates a album. Represents a collection of images, movies, and audio. Used when creating albums on the server.

Parameters:

NameTypeDescription
opt_paramsMap.<opensocial.Album.Field|Object>Any other fields that should be set on the Album object; all of the defined Field (Section 5.3.7) s are supported

Returns:

TypeDescription
opensocial.MediaItem (Section 5.3.36) The new album (Section 5.3.6) object
5.3.1.2.6 newDataRequest

<static> Type: { opensocial.DataRequest (Section 5.3.12) } opensocial.newDataRequest()

Description: Creates a data request object to use for sending and fetching data from the server.

Returns:

TypeDescription
opensocial.DataRequest (Section 5.3.12) The request (Section 5.3.12) object
5.3.1.2.7 newIdSpec

<static> Type: {opensocial.IdSpec} opensocial.newIdSpec(parameters)

Description: Creates an IdSpec object.

Parameters:

NameTypeDescription
parametersMap.<opensocial.IdSpec.Field|Object>Parameters defining the id spec.

Returns:

TypeDescription
opensocial.IdSpecThe new IdSpec (Section 5.3.32) object
5.3.1.2.8 newMediaItem

<static> Type: { opensocial.MediaItem (Section 5.3.36) } opensocial.newMediaItem(mimeType, url, opt_params)

Description: Creates a media item. Represents images, movies, and audio. Used when creating activities on the server.

Parameters:

NameTypeDescription
mimeTypeString MIME type (Section 5.3.38) of the media
urlStringWhere the media can be found
opt_paramsMap.<opensocial.MediaItem.Field|Object>Any other fields that should be set on the media item object; all of the defined Field (Section 5.3.37) s are supported

Returns:

TypeDescription
opensocial.MediaItem (Section 5.3.36) The new media item (Section 5.3.36) object
5.3.1.2.9 newMessage

<static> Type: { opensocial.Message (Section 5.3.39) } opensocial.newMessage(body, opt_params)

Description: Creates a new message object for use with opensocial.requestSendMessage.

Parameters:

NameTypeDescription
bodyStringThe main text of the message
opt_paramsMap.<opensocial.Message.Field|Object>Any other fields that should be set on the message object; all of the defined Field (Section 5.3.40) s are supported

Returns:

TypeDescription
opensocial.Message (Section 5.3.39) The new message (Section 5.3.39) object
5.3.1.2.10 newNavigationParameters

<static> Type: {opensocial.NavigationParameters} opensocial.newNavigationParameters(parameters)

Description: Creates a NavigationParameters object.

See also: requestShareApp() (Section 5.3.1.2.14)

Parameters:

NameTypeDescription
parametersMap.<opensocial.NavigationParameters.Field|Object>Parameters defining the navigation

Returns:

TypeDescription
opensocial.NavigationParametersThe new NavigationParameters (Section 5.3.45) object
5.3.1.2.11 requestCreateActivity

<static> opensocial.requestCreateActivity(activity, priority, opt_callback)

Description: Takes an activity and tries to create it, without waiting for the operation to complete. Optionally calls a function when the operation completes.

See also: newActivity() (Section 5.3.1.2.4)

Note: If this is the first activity that has been created for the user and the request is marked as HIGH priority then this call may open a user flow and navigate away from your gadget.

This callback will either be called or the gadget will be reloaded from scratch. This function will be passed one parameter, an opensocial.ResponseItem. The error code will be set to reflect whether there were any problems with the request. If there was no error, the activity was created. If there was an error, you can use the response item's getErrorCode method to determine how to proceed. The data on the response item will not be set.

If the container does not support this method the callback will be called with a opensocial.ResponseItem. The response item will have its error code set to NOT_IMPLEMENTED.

Parameters:

NameTypeDescription
activityopensocial.ActivityThe activity (Section 5.3.2) to create
priorityopensocial.CreateActivityPriorityThe priority (Section 5.3.11) for this request
opt_callbackFunctionThe function to call once the request has been processed. The callback function will not be called until after the existing callstack has completed execution.
5.3.1.2.12 requestPermission

<static> opensocial.requestPermission(permissions, reason, opt_callback)

Description: Requests the user to grant access to the specified permissions. If the container does not support this method the callback will be called with a opensocial.ResponseItem. The response item will have its error code set to NOT_IMPLEMENTED.

Parameters:

NameTypeDescription
permissionsArray.<opensocial.Permission>The permissions (Section 5.3.50) to request from the viewer
reasonStringDisplayed to the user as the reason why these permissions are needed
opt_callbackFunctionThe function to call once the request has been processed; either this callback will be called or the gadget will be reloaded from scratch. This function will be passed one parameter, an opensocial.ResponseItem. The error code will be set to reflect whether there were any problems with the request. If there was no error, all permissions were granted. If there was an error, you can use opensocial.hasPermission to check which permissions are still denied. The data on the response item will be set. It will be an array of the opensocial.Permissions that were granted. The callback function will not be called until after the existing callstack has completed execution.
5.3.1.2.13 requestSendMessage

<static> opensocial.requestSendMessage(An, message, opt_callback, opt_params)

Description: Requests the container to send a specific message to the specified users.

The callback function is passed one parameter, an opensocial.ResponseItem. The error code will be set to reflect whether there were any problems with the request. If there was no error, the message was sent. If there was an error, you can use the response item's getErrorCode method to determine how to proceed. The data on the response item will not be set.

If the container does not support this method the callback will be called with an opensocial.ResponseItem that has an error code of NOT_IMPLEMENTED.

Parameters:

NameTypeDescription
Anopensocial.IdSpecIdSpec used to specify which people/groups to send the message to.
messageopensocial.MessageThe message to send to the specified users
opt_callbackFunctionThe function to call once the request has been processed; either this callback will be called or the gadget will be reloaded from scratch.The callback function will not be called until after the existing callstack has completed execution.
opt_paramsopensocial.NavigationParametersThe optional parameters indicating where to send a user when a request is made, or when a request is accepted; options are of type NavigationParameters.DestinationType (Section 5.3.46)
5.3.1.2.14 requestShareApp

<static> opensocial.requestShareApp(recipients, reason, opt_callback, opt_params)

Description: Requests the container to share this gadget with the specified users.

The callback function is passed one parameter, an opensocial.ResponseItem. The error code will be set to reflect whether there were any problems with the request. If there was no error, the sharing request was sent. If there was an error, you can use the response item's getErrorCode method to determine how to proceed. The data on the response item will not be set.

If the container does not support this method the callback will be called with a opensocial.ResponseItem. The response item will have its error code set to NOT_IMPLEMENTED.

Parameters:

NameTypeDescription
recipientsopensocial.IdSpecAn IdSpec used to specify which people/groups to send the ShareApp request to.
reasonopensocial.MessageThe reason the user wants the gadget to share itself. This reason can be used by the container when prompting the user for permission to share the app. It may also be ignored.
opt_callbackFunctionThe function to call once the request has been processed; either this callback will be called or the gadget will be reloaded from scratch. The callback function will not be called until after the existing callstack has completed execution.
opt_paramsopensocial.NavigationParametersThe optional parameters indicating where to send a user when a request is made, or when a request is accepted; options are of type NavigationParameters.DestinationType (Section 5.3.46)
5.3.1.2.15 requestUploadMediaItem

<static> opensocial.requestUploadMediaItem(albumId, opt_callback)

Description: Uploads a media item. Allows the container to provide some standard UI and other items to post files to a site.

Parameters:

NameTypeDescription
albumIdstringIndicates which album/collection to insert the items into. If not present or set to null|undefined, the items go into the default location for the container. Partial upload is possible, such that if the container allows for multiple items, some items may fail to be added.
opt_callbackFunctionMethod is called when the upload completes. The callback function is passed one parameter, an opensocial.ResponseItem. The error code will be set to reflect whether there were any problems with the request. If there was no error, the message was sent. If there was an error, you can use the response item's getErrorCode method to determine how to proceed. getErrorMessage will contain a comma separated list of files that failed to upload. The data on the response item will be set to an array of media item (Section 5.3.36) objects for successful items.

5.3.2 opensocial.Activity

Representation of an activity.

Activities are rendered with a title and an optional activity body.

You may set the title and body directly as strings when calling opensocial.newActivity. However, it is usually beneficial to create activities using Message Templates for the title and body.

Users will have many activities in their activity streams, and containers will not show every activity that is visible to a user. To help display large numbers of activities, containers will summarize a list of activities from a given source to a single entry.

You can provide Activity Summaries to customize the text shown when multiple activities are summarized. If no customization is provided, a container may ignore your activities altogether or provide default text such as "Bob changed his status message + 20 other events like this."

Example summaries:

<messagebundle>
    <msg name="LISTEN_TO_THIS_SONG:Artist">
        ${Subject.Count} of your friends have suggested listening to songs
        by ${Artist}!
    </msg>
    <msg name="LISTEN_TO_THIS_SONG:Song">
        ${Subject.Count} of your friends have suggested listening to ${Song}
    !</msg>
    <msg name="LISTEN_TO_THIS_SONG:Subject">
        ${Subject.DisplayName} has recommended ${Song.Count} songs to you.
    </msg>
</messagebundle>

See also: opensocial.Message (Section 5.3.39), opensocial.newActivity() (Section 5.3.1.2.4), opensocial.requestCreateActivity() (Section 5.3.1.2.11)

5.3.2.1 Constructor

opensocial.Activity()

5.3.2.2 Method Details

5.3.2.2.1 getField

Type: {String} getField(key, opt_params)

Description: Gets the activity data that's associated with the specified key.

Parameters:

NameTypeDescription
keyStringThe key to get data for; see the Field (Section 5.3.3) class for possible values
opt_paramsMap.<opensocial.DataRequest.DataRequestFields|Object>Additional params (Section 5.3.15) to pass to the request.

Returns:

TypeDescription
StringThe data
5.3.2.2.2 getId

Type: {String} getId()

Description: Gets an ID that can be permanently associated with this activity.

Returns:

TypeDescription
StringThe ID
5.3.2.2.3 setField

setField(key, data)

Description: Sets data for this activity associated with the given key.

Parameters:

NameTypeDescription
keyStringThe key to set data for
dataStringThe data to set

5.3.3 opensocial.Activity.Field

All of the fields that activities can have.

It is only required to set one of TITLE_ID or TITLE. In addition, if you are using any variables in your title or title template, you must set TEMPLATE_PARAMS.

Other possible fields to set are: URL, MEDIA_ITEMS, BODY_ID, BODY, EXTERNAL_ID, PRIORITY, STREAM_TITLE, STREAM_URL, STREAM_SOURCE_URL, and STREAM_FAVICON_URL.

Containers are only required to use TITLE_ID or TITLE, they may ignore additional parameters.

See also: opensocial.Activity.getField() (Section 5.3.2.2.1)

5.3.3.1 Constructor

opensocial.Activity.Field

5.3.3.2 Field Details

5.3.3.2.1 APP_ID

<static> Member of: opensocial.Activity.Field.APP_ID

Description:

A string specifying the application that this activity is associated with. This value can not be set.

This field may be used interchangeably with the string 'appId'.

5.3.3.2.2 BODY

<static> Member of: opensocial.Activity.Field.BODY

Description:

A string specifying an optional expanded version of an activity.

Bodies may only have the following HTML tags: <b> <i>, <a>, <span>. The container may ignore this formatting when rendering the activity.

This field may be used interchangeably with the string 'body'.

5.3.3.2.3 BODY_ID

<static> Member of: opensocial.Activity.Field.BODY_ID

Description:

A string specifying the body template message ID in the gadget spec.

The body is an optional expanded version of an activity.

Bodies may only have the following HTML tags: <b> <i>, <a>, <span>. The container may ignore this formatting when rendering the activity.

This field may be used interchangeably with the string 'bodyId'.

5.3.3.2.4 EXTERNAL_ID

<static> Member of: opensocial.Activity.Field.EXTERNAL_ID

Description:

An optional string ID generated by the posting application.

This field may be used interchangeably with the string 'externalId'.

5.3.3.2.5 ID

<static> Member of: opensocial.Activity.Field.ID

Description:

A string ID that is permanently associated with this activity. This value can not be set.

This field may be used interchangeably with the string 'id'.

5.3.3.2.6 MEDIA_ITEMS

<static> Member of: opensocial.Activity.Field.MEDIA_ITEMS

Description:

Any photos, videos, or images that should be associated with the activity. Higher priority ones are higher in the list. The data has type Array< MediaItem (Section 5.3.36) >.

This field may be used interchangeably with the string 'mediaItems'.

5.3.3.2.7 POSTED_TIME

<static> Member of: opensocial.Activity.Field.POSTED_TIME

Description:

A string specifying the time at which this activity took place in milliseconds since the epoch. This value can not be set.

This field may be used interchangeably with the string 'postedTime'.

5.3.3.2.8 PRIORITY

<static> Member of: opensocial.Activity.Field.PRIORITY

Description:

A number between 0 and 1 representing the relative priority of this activity in relation to other activities from the same source

This field may be used interchangeably with the string 'priority'.

5.3.3.2.9 STREAM_FAVICON_URL

<static> Member of: opensocial.Activity.Field.STREAM_FAVICON_URL

Description:

A string specifying the URL for the stream's favicon.

This field may be used interchangeably with the string 'streamFaviconUrl'.

5.3.3.2.10 STREAM_SOURCE_URL

<static> Member of: opensocial.Activity.Field.STREAM_SOURCE_URL

Description:

A string specifying the stream's source URL.

This field may be used interchangeably with the string 'streamSourceUrl'.

5.3.3.2.11 STREAM_TITLE

<static> Member of: opensocial.Activity.Field.STREAM_TITLE

Description:

A string specifing the title of the stream.

This field may be used interchangeably with the string 'streamTitle'.

5.3.3.2.12 STREAM_URL

<static> Member of: opensocial.Activity.Field.STREAM_URL

Description:

A string specifying the stream's URL.

This field may be used interchangeably with the string 'streamUrl'.

5.3.3.2.13 TEMPLATE_PARAMS

<static> Member of: opensocial.Activity.Field.TEMPLATE_PARAMS

Description:

A map of custom key/value pairs associated with this activity. These will be used for evaluation in templates.

The data has type Map<String, Object>. The object may be either a String or an opensocial.Person.

When passing in a person with key PersonKey, can use the following replacement variables in the template:

This field may be used interchangeably with the string 'templateParams'.

5.3.3.2.14 TITLE

<static> Member of: opensocial.Activity.Field.TITLE

Description:

A string specifying the primary text of an activity.

Titles may only have the following HTML tags: <b> <i>, <a>, <span>. The container may ignore this formatting when rendering the activity.

This field may be used interchangeably with the string 'title'.

5.3.3.2.15 TITLE_ID

<static> Member of: opensocial.Activity.Field.TITLE_ID

Description:

A string specifying the title template message ID in the gadget spec.

The title is the primary text of an activity.

Titles may only have the following HTML tags: <b> <i>, <a>, <span>. The container may ignore this formatting when rendering the activity.

This field may be used interchangeably with the string 'titleId'.

5.3.3.2.16 URL

<static> Member of: opensocial.Activity.Field.URL

Description:

A string specifying the URL that represents this activity.

This field may be used interchangeably with the string 'url'.

5.3.3.2.17 USER_ID

<static> Member of: opensocial.Activity.Field.USER_ID

Description:

The string ID of the user who this activity is for. This value can not be set.

This field may be used interchangeably with the string 'userId'.

5.3.4 opensocial.Address

Base interface for all address objects.

5.3.4.1 Constructor

opensocial.Address()

5.3.4.2 Method Details

5.3.4.2.1 getField

Type: {String} getField(key, opt_params)

Description: Gets data for this body type that is associated with the specified key.

Parameters:

NameTypeDescription
keyStringThe key to get data for; keys are defined in Address.Field (Section 5.3.5)
opt_paramsMap.<opensocial.DataRequest.DataRequestFields|Object>Additional params (Section 5.3.15) to pass to the request

Returns:

TypeDescription
StringThe data

5.3.5 opensocial.Address.Field

All of the fields that an address has. These are the supported keys for the Address.getField() (Section 5.3.4.2.1) method.

5.3.5.1 Constructor

opensocial.Address.Field

5.3.5.2 Field Details

5.3.5.2.1 COUNTRY

<static> Member of: opensocial.Address.Field.COUNTRY

Description: The country, specified as a string. This field may be used interchangeably with the string 'country'.

5.3.5.2.2 EXTENDED_ADDRESS

<static> Member of: opensocial.Address.Field.EXTENDED_ADDRESS

Description: The extended street address, specified as a string. This field may be used interchangeably with the string 'extendedAddress'.

5.3.5.2.3 LATITUDE

<static> Member of: opensocial.Address.Field.LATITUDE

Description: The latitude, specified as a number. This field may be used interchangeably with the string 'latitude'.

5.3.5.2.4 LOCALITY

<static> Member of: opensocial.Address.Field.LOCALITY

Description: The locality, specified as a string. This field may be used interchangeably with the string 'locality'.

5.3.5.2.5 LONGITUDE

<static> Member of: opensocial.Address.Field.LONGITUDE

Description: The longitude, specified as a number. This field may be used interchangeably with the string 'longitude'.

5.3.5.2.6 PO_BOX

<static> Member of: opensocial.Address.Field.PO_BOX

Description: The P.O. box of the address, if there is one; specified as a string. This field may be used interchangeably with the string 'poBox'.

5.3.5.2.7 POSTAL_CODE

<static> Member of: opensocial.Address.Field.POSTAL_CODE

Description: The postal code, specified as a string. This field may be used interchangeably with the string 'postalCode'.

5.3.5.2.8 REGION

<static> Member of: opensocial.Address.Field.REGION

Description: The region, specified as a string. This field may be used interchangeably with the string 'region'.

5.3.5.2.9 STREET_ADDRESS

<static> Member of: opensocial.Address.Field.STREET_ADDRESS

Description: The street address, specified as a string. This field may be used interchangeably with the string 'streetAddress'.

5.3.5.2.10 TYPE

<static> Member of: opensocial.Address.Field.TYPE

Description: The address type or label, specified as a string. Examples: work, my favorite store, my house, etc. This field may be used interchangeably with the string 'type'.

5.3.5.2.11 UNSTRUCTURED_ADDRESS

<static> Member of: opensocial.Address.Field.UNSTRUCTURED_ADDRESS

Description: If the container does not have structured addresses in its data store, this field contains the unstructured address that the user entered, specified as a string. Use opensocial.getEnvironment().supportsField to see which fields are supported. This field may be used interchangeably with the string 'unstructuredAddress'.

5.3.6 opensocial.Album

Class for Album features.

5.3.6.1 Constructor

opensocial.Album

5.3.6.2 Method Details

5.3.6.2.1 getField

Type: {String} getField(key, opt_params)

Description: Gets the album data that's associated with the specified key.

Parameters:

NameTypeDescription
keyStringThe key to get data for; see the Field (Section 5.3.7) class for possible values
opt_paramsMap.<opensocial.DataRequest.DataRequestFields|Object>Additional params (Section 5.3.15) to pass to the request.

Returns:

TypeDescription
StringThe data
5.3.6.2.2 setField

setField(key, data)

Description: Sets data for this album associated with the given key.

Parameters:

NameTypeDescription
keyStringThe key to set data for
dataStringThe data to set

5.3.7 opensocial.Album.Field

All of the fields that albums can have.

It is only required to set ID.

Other possible fields to set are: THUMBNAIL_URL, TITLE, DESCRIPTION, LOCATION, OWNER_ID, MEDIA_TYPE, MEDIA_MIME_TYPE, MEDIA_ITEM_COUNT.

See also: opensocial.Album.getField() (Section 5.3.6.2.1)

5.3.7.1 Constructor

opensocial.Album.Field

5.3.7.2 Field Details

5.3.7.2.1 DESCRIPTION

<static> Member of: opensocial.Album.Field.DESCRIPTION

Description: string, description of the album. May be used interchangeably with the string 'description'.

5.3.7.2.2 ID

<static> Member of: opensocial.Album.Field.ID

Description: string, unique identifier for the album. May be used interchangeably with the string 'id'.

5.3.7.2.3 LOCATION

<static> Member of: opensocial.Album.Field.LOCATION

Description: opensocial.Address, location corresponding to the album. May be used interchangeably with the string 'location'.

5.3.7.2.4 MEDIA_ITEM_COUNT

<static> Member of: opensocial.Album.Field.MEDIA_ITEM_COUNT

Description: integer, number of items in the album. May be used interchangeably with the string 'mediaItemCount'.

5.3.7.2.5 MEDIA_MIME_TYPE

<static> Member of: opensocial.Album.Field.MEDIA_MIME_TYPE

Description: array of strings identifying the mime-types of media items in the Album. May be used interchangeably with the string 'mediaMimeType'.

5.3.7.2.6 MEDIA_TYPE

<static> Member of: opensocial.Album.Field.MEDIA_TYPE

Description: array of MediaItem.TYPE, types of MediaItems in the Album. May be used interchangeably with the string 'mediaType'.

5.3.7.2.7 OWNER_ID

<static> Member of: opensocial.Album.Field.OWNER_ID

Description: string, ID of the owner of the album. May be used interchangeably with the string 'ownerId'.

5.3.7.2.8 THUMBNAIL_URL

<static> Member of: opensocial.Album.Field.THUMBNAIL_URL

Description: string, URL to a thumbnail cover of the album. May be used interchangeably with the string 'thumbnailUrl'.

5.3.7.2.9 TITLE

<static> Member of: opensocial.Album.Field.TITLE

Description: string, the title of the album. May be used interchangeably with the string 'title'.

5.3.8 opensocial.BodyType

Base interface for all body type objects.

5.3.8.1 Constructor

opensocial.BodyType()

5.3.8.2 Method Details

5.3.8.2.1 getField

Type: {String} getField(key, opt_params)

Description: Gets data for this body type that is associated with the specified key.

Parameters:

NameTypeDescription
keyStringThe key to get data for; keys are defined in BodyType.Field (Section 5.3.9)
opt_paramsMap.<opensocial.DataRequest.DataRequestFields|Object>Additional params (Section 5.3.15) to pass to the request.

Returns:

TypeDescription
StringThe data

5.3.9 opensocial.BodyType.Field

All of the fields that a body type has. These are the supported keys for the BodyType.getField() (Section 5.3.8.2.1) method.

5.3.9.1 Constructor

opensocial.BodyType.Field

5.3.9.2 Field Details

5.3.9.2.1 BUILD

<static> Member of: opensocial.BodyType.Field.BUILD

Description: The build of the person's body, specified as a string. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'build'.

5.3.9.2.2 EYE_COLOR

<static> Member of: opensocial.BodyType.Field.EYE_COLOR

Description: The eye color of the person, specified as a string. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'eyeColor'.

5.3.9.2.3 HAIR_COLOR

<static> Member of: opensocial.BodyType.Field.HAIR_COLOR

Description: The hair color of the person, specified as a string. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'hairColor'.

5.3.9.2.4 HEIGHT

<static> Member of: opensocial.BodyType.Field.HEIGHT

Description: The height of the person in meters, specified as a number. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'height'.

5.3.9.2.5 WEIGHT

<static> Member of: opensocial.BodyType.Field.WEIGHT

Description: The weight of the person in kilograms, specified as a number. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'weight'.

5.3.10 opensocial.Collection

Collection of multiple objects with useful accessors. May also represent subset of a larger collection (for example, page 1 of 10) and contain information about the larger collection.

5.3.10.1 Constructor

opensocial.Collection()

5.3.10.2 Method Details

5.3.10.2.1 asArray

Type: {Array.<Object>} asArray()

Description: Returns an array of all the objects in this collection.

Returns:

TypeDescription
Array.<Object>The values in this collection
5.3.10.2.2 each

each(fn)

Description: Executes the provided function once per member of the collection, with each member in turn as the parameter to the function.

Parameters:

NameTypeDescription
fnFunctionThe function to call with each collection entry
5.3.10.2.3 getById

Type: {Object?} getById(id)

Description: Finds the entry with the given ID value, or returns null if none is found.

Parameters:

NameTypeDescription
idStringThe ID to look for

Returns:

TypeDescription
Object?The data
5.3.10.2.4 getOffset

Type: {Number} getOffset()

Description: Gets the offset of this collection within a larger result set.

Returns:

TypeDescription
NumberThe offset into the total collection
5.3.10.2.5 getTotalSize

Type: {Number} getTotalSize()

Description: Gets the total size of the larger result set that this collection belongs to.

Returns:

TypeDescription
NumberThe total size of the result
5.3.10.2.6 size

Type: {Number} size()

Description: Gets the size of this collection, which is equal to or less than the total size of the result.

Returns:

TypeDescription
NumberThe size of this collection

5.3.11 opensocial.CreateActivityPriority

The priorities a create activity request can have.

See also: opensocial.requestCreateActivity() (Section 5.3.1.2.11)

5.3.11.1 Constructor

opensocial.CreateActivityPriority

5.3.11.2 Field Details

5.3.11.2.1 HIGH

<static> Member of: opensocial.CreateActivityPriority.HIGH

Description: If the activity is of high importance, it will be created even if this requires asking the user for permission. This may cause the container to open a user flow which may navigate away from your gagdet. This field may be used interchangeably with the string 'HIGH'.

5.3.11.2.2 LOW

<static> Member of: opensocial.CreateActivityPriority.LOW

Description: If the activity is of low importance, it will not be created if the user has not given permission for the current app to create activities. With this priority, the requestCreateActivity call will never open a user flow. This field may be used interchangeably with the string 'LOW'.

5.3.12 opensocial.DataRequest

Used to request social information from the container. This includes data for friends, profiles, app data, and activities. All apps that require access to people information should send a DataRequest.

Here's an example of creating, initializing, sending, and handling the results of a data request:

function requestMe() {
    var req = opensocial.newDataRequest();
    req.add(req.newFetchPersonRequest(
        opensocial.IdSpec.PersonId.VIEWER),
        "viewer");
    req.send(handleRequestMe);
};
function handleRequestMe(data) {
    var viewer = data.get("viewer");
    if (viewer.hadError()) {
        //Handle error using viewer.getError()...return;
    }
    //No error. Do something with viewer.getData()...
}

See also: opensocial.newDataRequest() (Section 5.3.1.2.6)

5.3.12.1 Constructor

opensocial.DataRequest()

5.3.12.2 Method Details

5.3.12.2.1 add

add(request, opt_key)

Description: Adds an item to fetch (get) or update (set) data from the server. A single DataRequest object can have multiple items. As a rule, each item is executed in the order it was added, starting with the item that was added first. However, items that can't collide might be executed in parallel.

Parameters:

NameTypeDescription
requestObjectSpecifies which data to fetch or update
opt_keyStringA key to map the generated response data to
5.3.12.2.2 newCreateAlbumRequest

Type: {Object} newCreateAlbumRequest(An, album)

Description: Creates a new album and returns the ID of the album created. Containers implement restrictions - like allowing a viewer to create albums for only him/herself.

Parameters:

NameTypeDescription
Anopensocial.IdSpecIdSpec used to specify which people/groups to create an album for.
albumopensocail.AlbumThe album to create.

Returns:

TypeDescription
ObjectA request object
5.3.12.2.3 newCreateMediaItemRequest

Type: {Object} newCreateMediaItemRequest(An, albumId, mediaItem)

Description: Creates a new media item in the album and returns the ID of the album created. Containers implement restrictions.

Parameters:

NameTypeDescription
Anopensocial.IdSpecIdSpec used to specify which people/groups own the album.
albumIdstringThe album to add the media item to.
mediaItemopensocial.MediaItemThe MediaItem to add to the album.

Returns:

TypeDescription
ObjectA request object
5.3.12.2.4 newDeleteAlbumRequest

Type: {Object} newDeleteAlbumRequest(An, albumId)

Description: Deletes the album specified. Containers implement restriction.

Parameters:

NameTypeDescription
Anopensocial.IdSpecIdSpec used to specify which people/groups own the album.
albumIdstringThe album to delete.

Returns:

TypeDescription
ObjectA request object
5.3.12.2.5 newFetchActivitiesRequest

Type: {Object} newFetchActivitiesRequest(idSpec, opt_params)

Description: Creates an item to request an activity stream from the server.

When processed, returns a Collection<Activity>.

Parameters:

NameTypeDescription
idSpecopensocial.IdSpecAn IdSpec used to specify which people to fetch. See also IdSpec (Section 5.3.32).
opt_paramsMap.<opensocial.DataRequest.ActivityRequestFields|Object>Additional parameters to pass to the request; not currently used

Returns:

TypeDescription
ObjectA request object
5.3.12.2.6 newFetchAlbumsRequest

Type: {Object} newFetchAlbumsRequest(An, opt_params)

Description: The newFetchAlbumsRequest() creates an object for DataRequest to request albums.

Parameters:

NameTypeDescription
Anopensocial.IdSpecIdSpec used to specify which people/groups to fetch albums from.
opt_paramsMap.<string|string>opt_params can specify the following: opensocial.Album.Field.ID - an array of album Ids to fetch (fetch all albums if empty, subject to pagination) opensocial.Album.Field.MEDIA_TYPE - an array of MediaItem.TYPE values to specify the kind of Albums to fetch. opensocial.DataRequest.AlbumRequestFields.FIRST - The first item to fetch. opensocial.DataRequest.AlbumRequestFields.MAX - The maximum number of items to fetch.

Returns:

TypeDescription
ObjectA request object
5.3.12.2.7 newFetchMediaItemsRequest

Type: {Object} newFetchMediaItemsRequest(An, albumId, opt_params)

Description: The newFetchMediaItemsRequest() creates an object for DataRequest to request mediaItems.

Parameters:

NameTypeDescription
Anopensocial.IdSpecIdSpec used to specify which people/groups to fetch media items from.
albumIdstringThe id of the album to fetch MediaItems from.
opt_paramsMap.<string|string>opt_params can specify the following: opensocial.MediaItem.Field.ID - an array of media item ids to selectively fetch (fetch all items if empty, subject to pagination) opensocial.MediaItem.Field.MEDIA_TYPE - an array of MediaItem.TYPE values to specify the types of MediaItems to fetch opensocial.DataRequest.MediaItemRequestFields.FIRST - The first item to fetch. opensocial.DataRequest.MediaItemRequestFields.MAX - The maximum number of items to fetch.

Returns:

TypeDescription
ObjectA request object
5.3.12.2.8 newFetchPeopleRequest

Type: {Object} newFetchPeopleRequest(idSpec, opt_params)

Description: Creates an item to request friends from the server. When processed, returns a Collection (Section 5.3.10) < Person (Section 5.3.51) > object.

Parameters:

NameTypeDescription
idSpecopensocial.IdSpecAn IdSpec used to specify which people to fetch. See also IdSpec (Section 5.3.32).
opt_paramsMap.<opensocial.DataRequest.PeopleRequestFields|Object>Additional params (Section 5.3.18) to pass to the request

Returns:

TypeDescription
ObjectA request object
5.3.12.2.9 newFetchPersonAppDataRequest

Type: {Object} newFetchPersonAppDataRequest(idSpec, keys, opt_params)

Description: Creates an item to request app data for the given people. When processed, returns a Map< PersonId (Section 5.3.35), Map<String, Object>> object. All of the data values returned will be valid json.

Parameters:

NameTypeDescription
idSpecopensocial.IdSpecAn IdSpec used to specify which people to fetch. See also IdSpec (Section 5.3.32).
keysArray.<String> | StringThe keys you want data for; this can be an array of key names, a single key name, or "*" to mean "all keys"
opt_paramsMap.<opensocial.DataRequest.DataRequestFields|Object>Additional params (Section 5.3.15) to pass to the request

Returns:

TypeDescription
ObjectA request object
5.3.12.2.10 newFetchPersonRequest

Type: {Object} newFetchPersonRequest(id, opt_params)

Description: Creates an item to request a profile for the specified person ID. When processed, returns a Person (Section 5.3.51) object.

Parameters:

NameTypeDescription
idStringThe ID of the person to fetch; can be the standard person ID (Section 5.3.35) of VIEWER or OWNER
opt_paramsMap.<opensocial.DataRequest.PeopleRequestFields|Object>Additional parameters (Section 5.3.18) to pass to the request; this request supports PROFILE_DETAILS

Returns:

TypeDescription
ObjectA request object
5.3.12.2.11 newRemovePersonAppDataRequest

Type: {Object} newRemovePersonAppDataRequest(keys)

Description: Deletes the given keys from the datastore for the current VIEWER. When processed, does not return any data.

Parameters:

NameTypeDescription
keysArray.<String> | StringThe keys you want to delete from the datastore; this can be an array of key names, a single key name, or "*" to mean "all keys"

Returns:

TypeDescription
ObjectA request object
5.3.12.2.12 newUpdateAlbumRequest

Type: {Object} newUpdateAlbumRequest(An, albumId, fields)

Description: Updates the fields specified in the params.The following fields cannot be set: MEDIA_ITEM_COUNT, OWNER_ID, ID. Containers implement restrictions.

Parameters:

NameTypeDescription
Anopensocial.IdSpecIdSpec used to specify which people/groups to own the album.
albumIdstringThe album to update.
fieldsMap<opensocial.Album.Field|object>The Album Fields to update.The following fields cannot be set: MEDIA_ITEM_COUNT, OWNER_ID, ID. Containers implement restrictions.

Returns:

TypeDescription
ObjectA request object
5.3.12.2.13 newUpdateMediaItemRequest

Type: {Object} newUpdateMediaItemRequest(An, albumId, mediaItemId, fields)

Description: Updates the fields specified in the params.The following fields cannot be set: ID, CREATED, ALBUM_ID, FILE_SIZE, NUM_COMMENTS. Containers implement restrictions.

Parameters:

NameTypeDescription
Anopensocial.IdSpecIdSpec used to specify which people/groups own the album/media item.
albumIdstringThe album containing the media item to update.
mediaItemIdstringThe media item to update.
fieldsMap<opensocial.MediaItem.Field|object>The Album Fields to update.The following fields cannot be set: ID, CREATED, ALBUM_ID, FILE_SIZE, NUM_COMMENTS. Containers implement restrictions.

Returns:

TypeDescription
ObjectA request object
5.3.12.2.14 newUpdatePersonAppDataRequest

Type: {Object} newUpdatePersonAppDataRequest(key, value)

Description: Creates an item to request an update of an app field for the current VIEWER. When processed, does not return any data. App Data is stored as a series of key value pairs of strings, scoped per person, per application.

Parameters:

NameTypeDescription
keyStringThe name of the key. This may only contain alphanumeric (A-Za-z0-9) characters, underscore(_), dot(.) or dash(-).
valueObjectThe value, must be valid json

Returns:

TypeDescription
ObjectA request object
5.3.12.2.15 send

send(opt_callback)

Description: Sends a data request to the server in order to get a data response. Although the server may optimize these requests, they will always be executed as though they were serial.

Parameters:

NameTypeDescription
opt_callbackFunctionThe function to call with the data response (Section 5.3.20) generated by the server. The callback function will not be called until after the existing callstack has completed execution.

5.3.13 opensocial.DataRequest.ActivityRequestFields

The values needed to handle activity paging.

5.3.13.1 Constructor

opensocial.DataRequest.ActivityRequestFields

5.3.13.2 Field Details

5.3.13.2.1 FIRST

<static> Member of: opensocial.DataRequest.ActivityRequestFields.FIRST

Description: When paginating, the index of the first item to fetch; specified as a number.

5.3.13.2.2 MAX

<static> Member of: opensocial.DataRequest.ActivityRequestFields.MAX

Description: The maximum number of items to fetch, specified as a number; defaults to 20.

5.3.14 opensocial.DataRequest.AlbumRequestFields

The values needed to handle activity paging.

5.3.14.1 Constructor

opensocial.DataRequest.AlbumRequestFields

5.3.14.2 Field Details

5.3.14.2.1 FIRST

<static> Member of: opensocial.DataRequest.AlbumRequestFields.FIRST

Description: When paginating, the index of the first item to fetch; specified as a number.

5.3.14.2.2 MAX

<static> Member of: opensocial.DataRequest.AlbumRequestFields.MAX

Description: The maximum number of items to fetch, specified as a number; defaults to 20.

5.3.15 opensocial.DataRequest.DataRequestFields

5.3.15.1 Constructor

opensocial.DataRequest.DataRequestFields

5.3.15.2 Field Details

5.3.15.2.1 ESCAPE_TYPE

<static> Member of: opensocial.DataRequest.DataRequestFields.ESCAPE_TYPE

Description: How to escape person data returned from the server; defaults to HTML_ESCAPE. Possible values are defined by EscapeType (Section 5.3.31). This field may be used interchangeably with the string 'escapeType'. Use of this function is deprecated in favor of us using the ESCAPE_TYPE (Section 5.3.18.2.2) request field.

5.3.16 opensocial.DataRequest.FilterType

The filters available for limiting person requests.

5.3.16.1 Constructor

opensocial.DataRequest.FilterType

5.3.16.2 Field Details

5.3.16.2.1 ALL

<static> Member of: opensocial.DataRequest.FilterType.ALL

Description: Retrieves all friends. This field may be used interchangeably with the string 'all'.

5.3.16.2.2 HAS_APP

<static> Member of: opensocial.DataRequest.FilterType.HAS_APP

Description: Retrieves all friends that use this application. Note: Containers may define "use" in any manner they deem appropriate for their functionality, and it is not expected that this field will have the exact same semantics across containers. This field may be used interchangeably with the string 'hasApp'.

5.3.16.2.3 IS_FRIENDS_WITH

<static> Member of: opensocial.DataRequest.FilterType.IS_FRIENDS_WITH

Description: Will filter the people requested by checking if they are friends with the given idSpec (Section 5.3.32). Expects a filterOptions parameter to be passed with the following fields defined: - idSpec The idSpec (Section 5.3.32) that each person must be friends with. This field may be used interchangeably with the string 'isFriendsWith'.

5.3.16.2.4 TOP_FRIENDS

<static> Member of: opensocial.DataRequest.FilterType.TOP_FRIENDS

Description: Retrieves only the user's top friends as defined by the container. Container support for this filter type is OPTIONAL. This field may be used interchangeably with the string 'topFriends'.

5.3.17 opensocial.DataRequest.MediaItemRequestFields

The values needed to handle activity paging.

5.3.17.1 Constructor

opensocial.DataRequest.MediaItemRequestFields

5.3.17.2 Field Details

5.3.17.2.1 FIRST

<static> Member of: opensocial.DataRequest.MediaItemRequestFields.FIRST

Description: When paginating, the index of the first item to fetch; specified as a number.

5.3.17.2.2 MAX

<static> Member of: opensocial.DataRequest.MediaItemRequestFields.MAX

Description: The maximum number of items to fetch, specified as a number; defaults to 20.

5.3.18 opensocial.DataRequest.PeopleRequestFields

5.3.18.1 Constructor

opensocial.DataRequest.PeopleRequestFields

5.3.18.2 Field Details

5.3.18.2.1 APP_DATA

<static> Member of: opensocial.DataRequest.PeopleRequestFields.APP_DATA

Description: An array of strings, specifying the app data keys to fetch for each of the Person objects. This field may be used interchangeably with the string 'appData'.

5.3.18.2.2 ESCAPE_TYPE

<static> Member of: opensocial.DataRequest.PeopleRequestFields.ESCAPE_TYPE

Description: How to escape Person fields and app data returned from the server; defaults to HTML_ESCAPE. Possible values are defined by EscapeType (Section 5.3.31). This field may be used interchangeably with the string 'escapeType'.

5.3.18.2.3 FILTER

<static> Member of: opensocial.DataRequest.PeopleRequestFields.FILTER

Description: How to filter the people objects; defaults to ALL. Possible values are defined by FilterType (Section 5.3.16). This field may be used interchangeably with the string 'filter'.

5.3.18.2.4 FILTER_OPTIONS

<static> Member of: opensocial.DataRequest.PeopleRequestFields.FILTER_OPTIONS

Description: Additional options to be passed into the filter, specified as a Map<String, Object>. This field may be used interchangeably with the string 'filterOptions'.

5.3.18.2.5 FIRST

<static> Member of: opensocial.DataRequest.PeopleRequestFields.FIRST

Description: When paginating, the index of the first item to fetch; specified as a number. This field may be used interchangeably with the string 'first'.

5.3.18.2.6 MAX

<static> Member of: opensocial.DataRequest.PeopleRequestFields.MAX

Description: The maximum number of items to fetch, specified as a number; defaults to 20. If set to a larger number, a container may honor the request, or may limit the number to a container-specified limit of at least 20. This field may be used interchangeably with the string 'max'.

5.3.18.2.7 PROFILE_DETAILS

<static> Member of: opensocial.DataRequest.PeopleRequestFields.PROFILE_DETAILS

Description: An array of opensocial.Person.Field (Section 5.3.52) specifying what profile data to fetch for each of the person objects. The server will always include ID, NAME, and THUMBNAIL_URL. This field may be used interchangeably with the string 'profileDetail'.

5.3.18.2.8 SORT_ORDER

<static> Member of: opensocial.DataRequest.PeopleRequestFields.SORT_ORDER

Description: A sort order for the people objects; defaults to TOP_FRIENDS. Possible values are defined by SortOrder (Section 5.3.19). This field may be used interchangeably with the string 'sortOrder'.

5.3.19 opensocial.DataRequest.SortOrder

The sort orders available for ordering person objects.

5.3.19.1 Constructor

opensocial.DataRequest.SortOrder

5.3.19.2 Field Details

5.3.19.2.1 NAME

<static> Member of: opensocial.DataRequest.SortOrder.NAME

Description: When used will sort people alphabetically by the name field. This field may be used interchangeably with the string 'name'.

5.3.19.2.2 TOP_FRIENDS

<static> Member of: opensocial.DataRequest.SortOrder.TOP_FRIENDS

Description: When used will sort people by the container's definition of top friends. This field may be used interchangeably with the string 'topFriends'.

5.3.20 opensocial.DataResponse

This object contains the requested server data mapped to the requested keys.

See also: DataRequest (Section 5.3.12)

5.3.20.1 Constructor

opensocial.DataResponse()

5.3.20.2 Method Details

5.3.20.2.1 get

Type: { opensocial.ResponseItem (Section 5.3.55) } get(key)

Description: Gets the ResponseItem for the requested field.

Parameters:

NameTypeDescription
key

Returns:

TypeDescription
opensocial.ResponseItem (Section 5.3.55) The requested response (Section 5.3.55) calculated by the server
5.3.20.2.2 getErrorMessage

Type: {String} getErrorMessage()

Description: If the entire request had a batch level error, returns the error message.

Returns:

TypeDescription
StringA human-readable description of the error that occurred.
5.3.20.2.3 hadError

Type: {Boolean} hadError()

Description: Returns true if there was an error in fetching this data from the server.

Returns:

TypeDescription
BooleanTrue if there was an error; otherwise, false

5.3.21 opensocial.Email

Base interface for all email objects.

5.3.21.1 Constructor

opensocial.Email()

5.3.21.2 Method Details

5.3.21.2.1 getField

Type: {String} getField(key, opt_params)

Description: Gets data for this body type that is associated with the specified key.

Parameters:

NameTypeDescription
keyStringThe key to get data for; keys are defined in Email.Field (Section 5.3.22)
opt_paramsMap.<opensocial.DataRequest.DataRequestFields|Object>Additional params (Section 5.3.15) to pass to the request.

Returns:

TypeDescription
StringThe data

5.3.22 opensocial.Email.Field

All of the fields that an email has. These are the supported keys for the Email.getField() (Section 5.3.21.2.1) method.

5.3.22.1 Constructor

opensocial.Email.Field

5.3.22.2 Field Details

5.3.22.2.1 ADDRESS

<static> Member of: opensocial.Email.Field.ADDRESS

Description: The email address, specified as a string. This field may be used interchangeably with the string 'address'.

5.3.22.2.2 TYPE

<static> Member of: opensocial.Email.Field.TYPE

Description: The email type or label, specified as a string. Examples: work, my favorite store, my house, etc. This field may be used interchangeably with the string 'type'.

5.3.23 opensocial.Enum

Base interface for all enum objects. This class allows containers to use constants for fields that are usually have a common set of values. There are two main ways to use this class.

If your gadget just wants to display how much of a smoker someone is, it can simply use:

html = "This person smokes: " + person.getField('smoker').getValue();

This value field will be correctly set up by the container. This is a place where the container can even localize the value for the gadget so that it always shows the right thing.

If your gadget wants to have some logic around the smoker field it can use:

if (person.getField('smoker').getKey() != "NO") { //gadget logic here }

Note: The key may be null if the person's smoker field cannot be coerced into one of the standard enum types. The value, on the other hand, is never null.

5.3.23.1 Constructor

opensocial.Enum()

5.3.23.2 Method Details

5.3.23.2.1 getDisplayValue

Type: {String} getDisplayValue()

Description: The value of this enum. This will be a user displayable string. If the container supports localization, the string will be localized.

Returns:

TypeDescription
StringThe enum's value.
5.3.23.2.2 getKey

Type: {String} getKey()

Description: Use this for logic within your gadget. If they key is null then the value does not fit in the defined enums.

Returns:

TypeDescription
StringThe enum's key. This should be one of the defined enums below.

5.3.24 opensocial.Enum.Drinker

The enum keys used by the drinker field.

See also: opensocial.Person.Field.Drinker (Section 5.3.52)

5.3.24.1 Constructor

opensocial.Enum.Drinker

5.3.24.2 Field Details

5.3.24.2.1 HEAVILY

<static> Member of: opensocial.Enum.Drinker.HEAVILY

Description: This field may be used interchangeably with the string 'HEAVILY'.

5.3.24.2.2 NO

<static> Member of: opensocial.Enum.Drinker.NO

Description: This field may be used interchangeably with the string 'NO'.

5.3.24.2.3 OCCASIONALLY

<static> Member of: opensocial.Enum.Drinker.OCCASIONALLY

Description: This field may be used interchangeably with the string 'OCCASIONALLY'.

5.3.24.2.4 QUIT

<static> Member of: opensocial.Enum.Drinker.QUIT

Description: This field may be used interchangeably with the string 'QUIT'.

5.3.24.2.5 QUITTING

<static> Member of: opensocial.Enum.Drinker.QUITTING

Description: This field may be used interchangeably with the string 'QUITTING'.

5.3.24.2.6 REGULARLY

<static> Member of: opensocial.Enum.Drinker.REGULARLY

Description: This field may be used interchangeably with the string 'REGULARLY'.

5.3.24.2.7 SOCIALLY

<static> Member of: opensocial.Enum.Drinker.SOCIALLY

Description: This field may be used interchangeably with the string 'SOCIALLY'.

5.3.24.2.8 YES

<static> Member of: opensocial.Enum.Drinker.YES

Description: This field may be used interchangeably with the string 'YES'.

5.3.25 opensocial.Enum.Gender

The enum keys used by the gender field.

See also: opensocial.Person.Field.Gender (Section 5.3.52)

5.3.25.1 Constructor

opensocial.Enum.Gender

5.3.25.2 Field Details

5.3.25.2.1 FEMALE

<static> Member of: opensocial.Enum.Gender.FEMALE

Description: This field may be used interchangeably with the string 'FEMALE'.

5.3.25.2.2 MALE

<static> Member of: opensocial.Enum.Gender.MALE

Description: This field may be used interchangeably with the string 'MALE'.

5.3.26 opensocial.Enum.LookingFor

The enum keys used by the lookingFor field.

See also: opensocial.Person.Field.LookingFor (Section 5.3.52)

5.3.26.1 Constructor

opensocial.Enum.LookingFor

5.3.26.2 Field Details

5.3.26.2.1 ACTIVITY_PARTNERS

<static> Member of: opensocial.Enum.LookingFor.ACTIVITY_PARTNERS

Description: This field may be used interchangeably with the string 'ACTIVITY_PARTNERS'.

5.3.26.2.2 DATING

<static> Member of: opensocial.Enum.LookingFor.DATING

Description: This field may be used interchangeably with the string 'DATING'.

5.3.26.2.3 FRIENDS

<static> Member of: opensocial.Enum.LookingFor.FRIENDS

Description: This field may be used interchangeably with the string 'FRIENDS'.

5.3.26.2.4 NETWORKING

<static> Member of: opensocial.Enum.LookingFor.NETWORKING

Description: This field may be used interchangeably with the string 'NETWORKING'.

5.3.26.2.5 RANDOM

<static> Member of: opensocial.Enum.LookingFor.RANDOM

Description: This field may be used interchangeably with the string 'RANDOM'.

5.3.26.2.6 RELATIONSHIP

<static> Member of: opensocial.Enum.LookingFor.RELATIONSHIP

Description: This field may be used interchangeably with the string 'RELATIONSHIP'.

5.3.27 opensocial.Enum.Presence

The enum keys used by the networkPresence field.

See also: opensocial.Person.Field.NetworkPresence (Section 5.3.52)

5.3.27.1 Constructor

opensocial.Enum.Presence

5.3.27.2 Field Details

5.3.27.2.1 AWAY

<static> Member of: opensocial.Enum.Presence.AWAY

Description: The entity or resource is temporarily away. This field may be used interchangeably with the string 'AWAY'.

5.3.27.2.2 CHAT

<static> Member of: opensocial.Enum.Presence.CHAT

Description: The entity or resource is actively interested in chatting. This field may be used interchangeably with the string 'CHAT'.

5.3.27.2.3 DND

<static> Member of: opensocial.Enum.Presence.DND

Description: The entity or resource is busy (dnd = "Do Not Disturb"). This field may be used interchangeably with the string 'DND'.

5.3.27.2.4 OFFLINE

<static> Member of: opensocial.Enum.Presence.OFFLINE

Description: The entity or resource is off line. This field may be used interchangeably with the string 'OFFLINE'.

5.3.27.2.5 ONLINE

<static> Member of: opensocial.Enum.Presence.ONLINE

Description: The entity or resource is on line. This field may be used interchangeably with the string 'ONLINE'.

5.3.27.2.6 XA

<static> Member of: opensocial.Enum.Presence.XA

Description: The entity or resource is away for an extended period (xa = "eXtended Away"). This field may be used interchangeably with the string 'XA'.

5.3.28 opensocial.Enum.Smoker

The enum keys used by the smoker field.

See also: opensocial.Person.Field.Smoker (Section 5.3.52)

5.3.28.1 Constructor

opensocial.Enum.Smoker

5.3.28.2 Field Details

5.3.28.2.1 HEAVILY

<static> Member of: opensocial.Enum.Smoker.HEAVILY

Description: This field may be used interchangeably with the string 'HEAVILY'.

5.3.28.2.2 NO

<static> Member of: opensocial.Enum.Smoker.NO

Description: This field may be used interchangeably with the string 'NO'.

5.3.28.2.3 OCCASIONALLY

<static> Member of: opensocial.Enum.Smoker.OCCASIONALLY

Description: This field may be used interchangeably with the string 'OCCASIONALLY'.

5.3.28.2.4 QUIT

<static> Member of: opensocial.Enum.Smoker.QUIT

Description: This field may be used interchangeably with the string 'QUIT'.

5.3.28.2.5 QUITTING

<static> Member of: opensocial.Enum.Smoker.QUITTING

Description: This field may be used interchangeably with the string 'QUITTING'.

5.3.28.2.6 REGULARLY

<static> Member of: opensocial.Enum.Smoker.REGULARLY

Description: This field may be used interchangeably with the string 'REGULARLY'.

5.3.28.2.7 SOCIALLY

<static> Member of: opensocial.Enum.Smoker.SOCIALLY

Description: This field may be used interchangeably with the string 'SOCIALLY'.

5.3.28.2.8 YES

<static> Member of: opensocial.Enum.Smoker.YES

Description: This field may be used interchangeably with the string 'YES'.

5.3.29 opensocial.Environment

Represents the current environment for a gadget.

See also: opensocial.getEnvironment() (Section 5.3.1.2.1),

5.3.29.1 Constructor

opensocial.Environment()

5.3.29.2 Method Details

5.3.29.2.1 getDomain

Type: {String} getDomain()

Description: Returns the current domain. for example, "orkut.com" or "myspace.com".

Returns:

TypeDescription
StringThe domain
5.3.29.2.2 supportsField

Type: {Boolean} supportsField(objectType, fieldName)

Description: Returns true if the specified field is supported in this container on the given object type, and returns false otherwise.

Parameters:

NameTypeDescription
objectTypeopensocial.Environment.ObjectTypeThe object type (Section 5.3.30) to check for the field
fieldNameStringThe name of the field to check for

Returns:

TypeDescription
BooleanTrue if the field is supported on the specified object type

5.3.30 opensocial.Environment.ObjectType

The types of objects in this container.

See also: Environment.supportsField() (Section 5.3.29.2.2)

5.3.30.1 Constructor

opensocial.Environment.ObjectType

5.3.30.2 Field Details

5.3.30.2.1 ACTIVITY

<static> Member of: opensocial.Environment.ObjectType.ACTIVITY

Description: This field may be used interchangeably with the string 'activity'.

5.3.30.2.2 ADDRESS

<static> Member of: opensocial.Environment.ObjectType.ADDRESS

Description: This field may be used interchangeably with the string 'address'.

5.3.30.2.3 BODY_TYPE

<static> Member of: opensocial.Environment.ObjectType.BODY_TYPE

Description: This field may be used interchangeably with the string 'bodyType'.

5.3.30.2.4 EMAIL

<static> Member of: opensocial.Environment.ObjectType.EMAIL

Description: This field may be used interchangeably with the string 'email'.

5.3.30.2.5 FILTER_TYPE

<static> Member of: opensocial.Environment.ObjectType.FILTER_TYPE

Description: This field may be used interchangeably with the string 'filterType'.

5.3.30.2.6 MEDIA_ITEM

<static> Member of: opensocial.Environment.ObjectType.MEDIA_ITEM

Description: This field may be used interchangeably with the string 'mediaItem'.

5.3.30.2.7 MESSAGE

<static> Member of: opensocial.Environment.ObjectType.MESSAGE

Description: This field may be used interchangeably with the string 'message'.

5.3.30.2.8 MESSAGE_TYPE

<static> Member of: opensocial.Environment.ObjectType.MESSAGE_TYPE

Description: This field may be used interchangeably with the string 'messageType'.

5.3.30.2.9 NAME

<static> Member of: opensocial.Environment.ObjectType.NAME

Description: This field may be used interchangeably with the string 'name'.

5.3.30.2.10 ORGANIZATION

<static> Member of: opensocial.Environment.ObjectType.ORGANIZATION

Description: This field may be used interchangeably with the string 'organization'.

5.3.30.2.11 PERSON

<static> Member of: opensocial.Environment.ObjectType.PERSON

Description: This field may be used interchangeably with the string 'person'.

5.3.30.2.12 PHONE

<static> Member of: opensocial.Environment.ObjectType.PHONE

Description: This field may be used interchangeably with the string 'phone'.

5.3.30.2.13 SORT_ORDER

<static> Member of: opensocial.Environment.ObjectType.SORT_ORDER

Description: This field may be used interchangeably with the string 'sortOrder'.

5.3.30.2.14 URL

<static> Member of: opensocial.Environment.ObjectType.URL

Description: This field may be used interchangeably with the string 'url'.

5.3.31 opensocial.EscapeType

The types of escaping that can be applied to person data or fields.

5.3.31.1 Constructor

opensocial.EscapeType

5.3.31.2 Field Details

5.3.31.2.1 HTML_ESCAPE

<static> Member of: opensocial.EscapeType.HTML_ESCAPE

Description: When used will HTML-escape the data. This field may be used interchangeably with the string 'htmlEscape'.

5.3.31.2.2 NONE

<static> Member of: opensocial.EscapeType.NONE

Description: When used will not escape the data. This field may be used interchangeably with the string 'none'.

5.3.32 opensocial.IdSpec

Base interface for all id spec objects.

5.3.32.1 Constructor

opensocial.IdSpec()

5.3.32.2 Method Details

5.3.32.2.1 getField

Type: {String} getField(key, opt_params)

Description: Gets the id spec's data that's associated with the specified key.

Parameters:

NameTypeDescription
keyStringThe key to get data for; see the Field (Section 5.3.33) class for possible values
opt_paramsMap.<opensocial.DataRequest.DataRequestFields|Object>Additional params (Section 5.3.15) to pass to the request.

Returns:

TypeDescription
StringThe data
5.3.32.2.2 setField

setField(key, data)

Description: Sets data for this id spec associated with the given key.

Parameters:

NameTypeDescription
keyStringThe key to set data for
dataStringThe data to set

5.3.33 opensocial.IdSpec.Field

All of the fields that id specs can have.

See also: opensocial.IdSpec.getField() (Section 5.3.32.2.1)

5.3.33.1 Constructor

opensocial.IdSpec.Field

5.3.33.2 Field Details

5.3.33.2.1 GROUP_ID

<static> Member of: opensocial.IdSpec.Field.GROUP_ID

Description: A string representing the group id or one of the opensocial.IdSpec.GroupId values. Defaults to SELF. This field may be used interchangeably with the string 'groupId'.

5.3.33.2.2 NETWORK_DISTANCE

<static> Member of: opensocial.IdSpec.Field.NETWORK_DISTANCE

Description: An optional numeric parameter, used to specify how many "hops" are allowed between two people still considered part of the same group. This is 0 based, for example: A value of 0 means that the people are the same person. 1 would mean that the people were friends. And 2 would mean that there was a friend of a friend relationship. Defaults to 1 (they are both friends or directly in the same group). Not all containers will support networkDistances greater than 1. This field may be used interchangeably with the string 'networkDistance'.

5.3.33.2.3 USER_ID

<static> Member of: opensocial.IdSpec.Field.USER_ID

Description: A string or an array of strings representing the user id. Can be one of the opensocial.IdSpec.PersonId values. This field may be used interchangeably with the string 'userId'.

5.3.34 opensocial.IdSpec.GroupId

Constant group IDs available when fetching collections of people.

5.3.34.1 Constructor

opensocial.IdSpec.GroupId

5.3.34.2 Field Details

5.3.34.2.1 ALL

<static> Member of: opensocial.IdSpec.GroupId.ALL

Description: This field may be used interchangeably with the string 'ALL'.

5.3.34.2.2 FRIENDS

<static> Member of: opensocial.IdSpec.GroupId.FRIENDS

Description: This field may be used interchangeably with the string 'FRIENDS'.

5.3.34.2.3 SELF

<static> Member of: opensocial.IdSpec.GroupId.SELF

Description: This field may be used interchangeably with the string 'SELF'.

5.3.35 opensocial.IdSpec.PersonId

Constant person IDs available when fetching person information.

5.3.35.1 Constructor

opensocial.IdSpec.PersonId

5.3.35.2 Field Details

5.3.35.2.1 OWNER

<static> Member of: opensocial.IdSpec.PersonId.OWNER

Description: This field may be used interchangeably with the string 'OWNER'.

5.3.35.2.2 VIEWER

<static> Member of: opensocial.IdSpec.PersonId.VIEWER

Description: This field may be used interchangeably with the string 'VIEWER'.

5.3.36 opensocial.MediaItem

Represents images, movies, and audio. Create a MediaItem object using the opensocial.newMediaItem() (Section 5.3.1.2.8) method.

5.3.36.1 Constructor

opensocial.MediaItem()

5.3.36.2 Method Details

5.3.36.2.1 getField

Type: {String} getField(key, opt_params)

Description: Gets the media item data that's associated with the specified key.

Parameters:

NameTypeDescription
keyStringThe key to get data for; see the Field (Section 5.3.37) class for possible values
opt_paramsMap.<opensocial.DataRequest.DataRequestFields|Object>Additional params (Section 5.3.15) to pass to the request.

Returns:

TypeDescription
StringThe data
5.3.36.2.2 setField

setField(key, data)

Description: Sets data for this media item associated with the given key.

Parameters:

NameTypeDescription
keyStringThe key to set data for
dataStringThe data to set

5.3.37 opensocial.MediaItem.Field

All of the fields that media items have.

See also: opensocial.MediaItem.getField() (Section 5.3.36.2.1)

5.3.37.1 Constructor

opensocial.MediaItem.Field

5.3.37.2 Field Details

5.3.37.2.1 ALBUM_ID

<static> Member of: opensocial.MediaItem.Field.ALBUM_ID

Description: string, album to which the media item belongs This field may be used interchangeably with the string 'albumId'.

5.3.37.2.2 CREATED

<static> Member of: opensocial.MediaItem.Field.CREATED

Description: string, creation time associated with the media item - assigned by container in UTC This field may be used interchangeably with the string 'created'.

5.3.37.2.3 DESCRIPTION

<static> Member of: opensocial.MediaItem.Field.DESCRIPTION

Description: string, description of the media item This field may be used interchangeably with the string 'description'.

5.3.37.2.4 DURATION

<static> Member of: opensocial.MediaItem.Field.DURATION

Description: integer, for audio/video clips - playtime length in seconds. set to -1/not defined if unknown This field may be used interchangeably with the string 'duration'.

5.3.37.2.5 FILE_SIZE

<static> Member of: opensocial.MediaItem.Field.FILE_SIZE

Description: long, number of bytes (set to -1/undefined if unknown). This field may be used interchangeably with the string 'fileSize'.

5.3.37.2.6 ID

<static> Member of: opensocial.MediaItem.Field.ID

Description: string, id Associated with the media item This field may be used interchangeably with the string 'id'.

5.3.37.2.7 LANGUAGE

<static> Member of: opensocial.MediaItem.Field.LANGUAGE

Description: string, language associated with the media item in ISO 639-3 format This field may be used interchangeably with the string 'language'.

5.3.37.2.8 LAST_UPDATED

<static> Member of: opensocial.MediaItem.Field.LAST_UPDATED

Description: string, update time associated with the media item - assigned by container in UTC This field may be used interchangeably with the string 'lastUpdated'.

5.3.37.2.9 LOCATION

<static> Member of: opensocial.MediaItem.Field.LOCATION

Description: opensocial.Address, location corresponding to the media item This field may be used interchangeably with the string 'location'.

5.3.37.2.10 MIME_TYPE

<static> Member of: opensocial.MediaItem.Field.MIME_TYPE

Description: The MIME type of media, specified as a string. This field may be used interchangeably with the string 'mimeType'.

5.3.37.2.11 NUM_COMMENTS

<static> Member of: opensocial.MediaItem.Field.NUM_COMMENTS

Description: integer, number of comments on the photo. This field may be used interchangeably with the string 'numComments'.

5.3.37.2.12 NUM_VIEWS

<static> Member of: opensocial.MediaItem.Field.NUM_VIEWS

Description: integer, number of views for the media item. This field may be used interchangeably with the string 'numViews'.

5.3.37.2.13 NUM_VOTES

<static> Member of: opensocial.MediaItem.Field.NUM_VOTES

Description: integer, number of votes received for voting. This field may be used interchangeably with the string 'numVotes'.

5.3.37.2.14 RATING

<static> Member of: opensocial.MediaItem.Field.RATING

Description: integer, average rating of the media item on a scale of 0-10. This field may be used interchangeably with the string 'rating'.

5.3.37.2.15 START_TIME

<static> Member of: opensocial.MediaItem.Field.START_TIME

Description: string, for streaming/live content, time when the content is available. This field may be used interchangeably with the string 'startTime'.

5.3.37.2.16 TAGGED_PEOPLE

<static> Member of: opensocial.MediaItem.Field.TAGGED_PEOPLE

Description: array of strings, array of string (IDs) of people tagged in the media item This field may be used interchangeably with the string 'taggedPeople'.

5.3.37.2.17 TAGS

<static> Member of: opensocial.MediaItem.Field.TAGS

Description: array of strings, tags associated with this media item. This field may be used interchangeably with the string 'tags'.

5.3.37.2.18 THUMBNAIL_URL

<static> Member of: opensocial.MediaItem.Field.THUMBNAIL_URL

Description: string, URL to a thumbnail image of the media item This field may be used interchangeably with the string 'thumbnailUrl'.

5.3.37.2.19 TITLE

<static> Member of: opensocial.MediaItem.Field.TITLE

Description: string describing the media item This field may be used interchangeably with the string 'title'.

5.3.37.2.20 TYPE

<static> Member of: opensocial.MediaItem.Field.TYPE

Description: The type of media, specified as a MediaItem.Type (Section 5.3.38) object. This field may be used interchangeably with the string 'type'.

5.3.37.2.21 URL

<static> Member of: opensocial.MediaItem.Field.URL

Description: A string specifying the URL where the media can be found. This field may be used interchangeably with the string 'url'.

5.3.38 opensocial.MediaItem.Type

The possible types of media items.

See also: opensocial.MediaItem.Field (Section 5.3.37)

5.3.38.1 Constructor

opensocial.MediaItem.Type

5.3.38.2 Field Details

5.3.38.2.1 AUDIO

<static> Member of: opensocial.MediaItem.Type.AUDIO

Description: This field may be used interchangeably with the string 'audio'.

5.3.38.2.2 IMAGE

<static> Member of: opensocial.MediaItem.Type.IMAGE

Description: This field may be used interchangeably with the string 'image'.

5.3.38.2.3 VIDEO

<static> Member of: opensocial.MediaItem.Type.VIDEO

Description: This field may be used interchangeably with the string 'video'.

5.3.39 opensocial.Message

Base interface for all message objects. *

See also: opensocial.newMessage() (Section 5.3.1.2.9), opensocial.requestSendMessage() (Section 5.3.1.2.13)

5.3.39.1 Constructor

opensocial.Message()

5.3.39.2 Method Details

5.3.39.2.1 getField

Type: {String} getField(key, opt_params)

Description: Gets the message data that's associated with the specified key.

Parameters:

NameTypeDescription
keyStringThe key to get data for; see the Field (Section 5.3.40) class for possible values
opt_paramsMap.<opensocial.DataRequest.DataRequestFields|Object>Additional params (Section 5.3.15) to pass to the request.

Returns:

TypeDescription
StringThe data
5.3.39.2.2 setField

setField(key, data)

Description: Sets data for this message associated with the given key.

Parameters:

NameTypeDescription
keyStringThe key to set data for
dataStringThe data to set

5.3.40 opensocial.Message.Field

All of the fields that messages can have.

See also: opensocial.Message.getField() (Section 5.3.39.2.1)

5.3.40.1 Constructor

opensocial.Message.Field

5.3.40.2 Field Details

5.3.40.2.1 APP_URL

<static> Member of: opensocial.Message.Field.APP_URL

Description: Identifies the application that generated this message. This field may be used interchangeably with the string 'appUrl'.

5.3.40.2.2 BODY

<static> Member of: opensocial.Message.Field.BODY

Description: The main text of the message. HTML attributes are allowed and are sanitized by the container. This field may be used interchangeably with the string 'body'.

5.3.40.2.3 BODY_ID

<static> Member of: opensocial.Message.Field.BODY_ID

Description: The main text of the message as a message template. Specifies the message ID to use in the gadget xml. This field may be used interchangeably with the string 'bodyId'.

5.3.40.2.4 COLLECTION_IDS

<static> Member of: opensocial.Message.Field.COLLECTION_IDS

Description: Identifies the messages collection IDs this message is contained in. This field may be used interchangeably with the string 'collectionIds'.

5.3.40.2.5 ID

<static> Member of: opensocial.Message.Field.ID

Description: unique ID for this message. This field may be used interchangeably with the string 'id'.

5.3.40.2.6 IN_REPLY_TO

<static> Member of: opensocial.Message.Field.IN_REPLY_TO

Description: Message ID, use for threaded comments/messages. Reference the sematics of the Atom Threading model defined in rfc4685. URLs should be mapped to Atom <link rel="type" .../> This field may be used interchangeably with the string 'inReplyTo'.

5.3.40.2.7 RECIPIENTS

<static> Member of: opensocial.Message.Field.RECIPIENTS

Description: Array of person IDs. This field may be used interchangeably with the string 'recipients'.

5.3.40.2.8 REPLIES

<static> Member of: opensocial.Message.Field.REPLIES

Description: array of message ids. Reference the sematics of the Atom Threading model defined in rfc4685. URLs should be mapped to Atom <link rel="type" .../> This field may be used interchangeably with the string 'replies'.

5.3.40.2.9 SENDER_ID

<static> Member of: opensocial.Message.Field.SENDER_ID

Description: id of person who sent the message. This field may be used interchangeably with the string 'senderId'.

5.3.40.2.10 STATUS

<static> Member of: opensocial.Message.Field.STATUS

Description: Status of the message. (NEW, READ, DELETED). This field may be used interchangeably with the string 'status'.

5.3.40.2.11 TIME_SENT

<static> Member of: opensocial.Message.Field.TIME_SENT

Description: UTC time message was sent. This field may be used interchangeably with the string 'timeSent'.

5.3.40.2.12 TITLE

<static> Member of: opensocial.Message.Field.TITLE

Description: The title of the message. HTML attributes are allowed and are sanitized by the container. This field may be used interchangeably with the string 'title'.

5.3.40.2.13 TITLE_ID

<static> Member of: opensocial.Message.Field.TITLE_ID

Description: The title of the message as a message template. Specifies the message ID to use in the gadget xml. This field may be used interchangeably with the string 'titleId'.

5.3.40.2.14 TYPE

<static> Member of: opensocial.Message.Field.TYPE

Description: The title of the message, specified as an opensocial.Message.Type. This field may be used interchangeably with the string 'type'.

5.3.40.2.15 UPDATED

<static> Member of: opensocial.Message.Field.UPDATED

Description: last update for this message . This field may be used interchangeably with the string 'updated'.

5.3.40.2.16 URLS

<static> Member of: opensocial.Message.Field.URLS

Description: List of related URLs for this message. Supported URL types include 'alternate', alternate for for this mailbox (text/html being the most common). This field may be used interchangeably with the string 'urls'.

5.3.41 opensocial.MessageCollection

Class for MessageCollection features.

5.3.41.1 Constructor

opensocial.MessageCollection

5.3.41.2 Method Details

5.3.41.2.1 getField

Type: {String} getField(key, opt_params)

Description: Gets the MessageCollection data that's associated with the specified key.

Parameters:

NameTypeDescription
keyStringThe key to get data for; see the Field (Section 5.3.42) class for possible values
opt_paramsMap.<opensocial.DataRequest.DataRequestFields|Object>Additional params (Section 5.3.15) to pass to the request.

Returns:

TypeDescription
StringThe data
5.3.41.2.2 setField

setField(key, data)

Description: Sets data for this album associated with the given key.

Parameters:

NameTypeDescription
keyStringThe key to set data for
dataStringThe data to set

5.3.42 opensocial.MessageCollection.Field

All of the fields that a MessageCollection can have.

It is only required to set ID.

See also: opensocial.MessageCollection.getField() (Section 5.3.41.2.1)

5.3.42.1 Constructor

opensocial.MessageCollection.Field

5.3.42.2 Field Details

5.3.42.2.1 ID

<static> Member of: opensocial.MessageCollection.Field.ID

Description: string, unique ID for this message collection. May be used interchangeably with the string 'id'.

5.3.42.2.2 TITLE

<static> Member of: opensocial.MessageCollection.Field.TITLE

Description: string, the title of the MessageCollection. May be used interchangeably with the string 'title'.

5.3.42.2.3 TOTAL

<static> Member of: opensocial.MessageCollection.Field.TOTAL

Description: int, total number of messages in this group. May be used interchangeably with the string 'total'.

5.3.42.2.4 UNREAD

<static> Member of: opensocial.MessageCollection.Field.UNREAD

Description: int, number of unread messages in this group. May be used interchangeably with the string 'unread'.

5.3.42.2.5 UPDATED

<static> Member of: opensocial.MessageCollection.Field.UPDATED

Description: string, last datetime update for this message collection. May be used interchangeably with the string 'updated'.

5.3.42.2.6 URLS

<static> Member of: opensocial.MessageCollection.Field.URLS

Description: opensocial.Url, List of related URLs for this message collection. Supported URL types include: 1. icon: icon for this mailbox 2. alternate: alternate form for this mailbox (text/html being the most common) May be used interchangeably with the string 'urls'.

5.3.43 opensocial.Name

Base interface for all name objects.

5.3.43.1 Constructor

opensocial.Name()

5.3.43.2 Method Details

5.3.43.2.1 getField

Type: {String} getField(key, opt_params)

Description: Gets data for this name that is associated with the specified key.

Parameters:

NameTypeDescription
keyStringThe key to get data for; keys are defined in Name.Field (Section 5.3.44)
opt_paramsMap.<opensocial.DataRequest.DataRequestFields|Object>Additional params (Section 5.3.15) to pass to the request.

Returns:

TypeDescription
StringThe data

5.3.44 opensocial.Name.Field

All of the fields that a name has. These are the supported keys for the Name.getField() (Section 5.3.43.2.1) method.

5.3.44.1 Constructor

opensocial.Name.Field

5.3.44.2 Field Details

5.3.44.2.1 ADDITIONAL_NAME

<static> Member of: opensocial.Name.Field.ADDITIONAL_NAME

Description: The additional name, specified as a string. This field may be used interchangeably with the string 'additionalName'.

5.3.44.2.2 FAMILY_NAME

<static> Member of: opensocial.Name.Field.FAMILY_NAME

Description: The family name, specified as a string. This field may be used interchangeably with the string 'familyName'.

5.3.44.2.3 GIVEN_NAME

<static> Member of: opensocial.Name.Field.GIVEN_NAME

Description: The given name, specified as a string. This field may be used interchangeably with the string 'givenName'.

5.3.44.2.4 HONORIFIC_PREFIX

<static> Member of: opensocial.Name.Field.HONORIFIC_PREFIX

Description: The honorific prefix, specified as a string. This field may be used interchangeably with the string 'honorificPrefix'.

5.3.44.2.5 HONORIFIC_SUFFIX

<static> Member of: opensocial.Name.Field.HONORIFIC_SUFFIX

Description: The honorific suffix, specified as a string. This field may be used interchangeably with the string 'honorificSuffix'.

5.3.44.2.6 UNSTRUCTURED

<static> Member of: opensocial.Name.Field.UNSTRUCTURED

Description: The unstructured name, specified as a string. This field may be used interchangeably with the string 'unstructured'.

5.3.45 opensocial.NavigationParameters

Parameters used by RequestShareApp to instruct the container on where to go after the request is made. It could be used, for example, to specify where viewers get routed in one of two cases:

  1. After a user gets a shareApp invitation or receives a message a gadget developer should be able to send that user to a context sensitive place.
  2. After a viewer actually shares an app with someone else the gadget developer should be able to redirect the viewer to a context sensitive place.

5.3.45.1 Constructor

opensocial.NavigationParameters()

5.3.45.2 Method Details

5.3.45.2.1 getField

Type: {String} getField(key, opt_params)

Description: Gets the NavigationParameters' data that's associated with the specified key.

Parameters:

NameTypeDescription
keyStringThe key to get data for; see the Field (Section 5.3.47) class for possible values
opt_paramsMap.<opensocial.DataRequest.DataRequestFields|Object>Additional params (Section 5.3.15) to pass to the request.

Returns:

TypeDescription
StringThe data
5.3.45.2.2 setField

setField(key, data)

Description: Sets data for this NavigationParameters associated with the given key.

Parameters:

NameTypeDescription
keyStringThe key to set data for
dataObjectThe data to set

5.3.46 opensocial.NavigationParameters.DestinationType

The destinations available for navigation in requestShareApp (Section 5.3.1.2.14) and requestSendMessage (Section 5.3.1.2.13).

5.3.46.1 Constructor

opensocial.NavigationParameters.DestinationType

5.3.46.2 Field Details

5.3.46.2.1 RECIPIENT_DESTINATION

<static> Member of: opensocial.NavigationParameters.DestinationType.RECIPIENT_DESTINATION

Description: This field may be used interchangeably with the string 'recipientDestination'.

5.3.46.2.2 VIEWER_DESTINATION

<static> Member of: opensocial.NavigationParameters.DestinationType.VIEWER_DESTINATION

Description: This field may be used interchangeably with the string 'viewerDestination'.

5.3.47 opensocial.NavigationParameters.Field

All of the fields that NavigationParameters can have.

See also: opensocial.NavigationParameters.getField() (Section 5.3.45.2.1)

5.3.47.1 Constructor

opensocial.NavigationParameters.Field

5.3.47.2 Field Details

5.3.47.2.1 OWNER

<static> Member of: opensocial.NavigationParameters.Field.OWNER

Description: A string representing the owner id. This field may be used interchangeably with the string 'owner'.

5.3.47.2.2 PARAMETERS

<static> Member of: opensocial.NavigationParameters.Field.PARAMETERS

Description: An optional list of parameters passed to the gadget once the new view, with the new owner, has been loaded. This field may be used interchangeably with the string 'parameters'.

5.3.47.2.3 VIEW

<static> Member of: opensocial.NavigationParameters.Field.VIEW

Description: The gadgets.views.View to navigate to. This field may be used interchangeably with the string 'view'.

5.3.48 opensocial.Organization

Base interface for all organization objects.

5.3.48.1 Constructor

opensocial.Organization()

5.3.48.2 Method Details

5.3.48.2.1 getField

Type: {String} getField(key, opt_params)

Description: Gets data for this body type that is associated with the specified key.

Parameters:

NameTypeDescription
keyStringThe key to get data for; keys are defined in Organization.Field (Section 5.3.49)
opt_paramsMap.<opensocial.DataRequest.DataRequestFields|Object>Additional params (Section 5.3.15) to pass to the request

Returns:

TypeDescription
StringThe data

5.3.49 opensocial.Organization.Field

All of the fields that a organization has. These are the supported keys for the Organization.getField() (Section 5.3.48.2.1) method.

5.3.49.1 Constructor

opensocial.Organization.Field

5.3.49.2 Field Details

5.3.49.2.1 ADDRESS

<static> Member of: opensocial.Organization.Field.ADDRESS

Description: The address of the organization, specified as an opensocial.Address. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'address'.

5.3.49.2.2 DESCRIPTION

<static> Member of: opensocial.Organization.Field.DESCRIPTION

Description: A description or notes about the person's work in the organization, specified as a string. This could be the courses taken by a student, or a more detailed description about a Organization role. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'description'.

5.3.49.2.3 END_DATE

<static> Member of: opensocial.Organization.Field.END_DATE

Description: The date the person stopped at the organization, specified as a Date. A null date indicates that the person is still involved with the organization. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'endDate'.

5.3.49.2.4 FIELD

<static> Member of: opensocial.Organization.Field.FIELD

Description: The field the organization is in, specified as a string. This could be the degree pursued if the organization is a school. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'field'.

5.3.49.2.5 NAME

<static> Member of: opensocial.Organization.Field.NAME

Description: The name of the organization, specified as a string. For example, could be a school name or a job company. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'name'.

5.3.49.2.6 SALARY

<static> Member of: opensocial.Organization.Field.SALARY

Description: The salary the person receieves from the organization, specified as a string. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'salary'.

5.3.49.2.7 START_DATE

<static> Member of: opensocial.Organization.Field.START_DATE

Description: The date the person started at the organization, specified as a Date. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'startDate'.

5.3.49.2.8 SUB_FIELD

<static> Member of: opensocial.Organization.Field.SUB_FIELD

Description: The subfield the Organization is in, specified as a string. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'subField'.

5.3.49.2.9 TITLE

<static> Member of: opensocial.Organization.Field.TITLE

Description: The title or role the person has in the organization, specified as a string. This could be graduate student, or software engineer. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'title'.

5.3.49.2.10 WEBPAGE

<static> Member of: opensocial.Organization.Field.WEBPAGE

Description: A webpage related to the organization, specified as a string. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'webpage'.

5.3.50 opensocial.Permission

The permissions an app can ask for.

See also: opensocial.hasPermission() (Section 5.3.1.2.2), opensocial.requestPermission() (Section 5.3.1.2.12)

5.3.50.1 Constructor

opensocial.Permission

5.3.50.2 Field Details

5.3.50.2.1 VIEWER

<static> Member of: opensocial.Permission.VIEWER

Description: Access to the viewer person object This field may be used interchangeably with the string 'viewer'.

5.3.51 opensocial.Person

Base interface for all person objects.

5.3.51.1 Constructor

opensocial.Person()

5.3.51.2 Method Details

5.3.51.2.1 getAppData

Type: {String} getAppData(key)

Description: Gets the app data for this person that is associated with the specified key.

Parameters:

NameTypeDescription
keyStringThe key to get app data for.

Returns:

TypeDescription
StringThe corresponding app data.
5.3.51.2.2 getDisplayName

Type: {String} getDisplayName()

Description: Gets a text display name for this person; guaranteed to return a useful string.

Returns:

TypeDescription
StringThe display name
5.3.51.2.3 getField

Type: {String} getField(key, opt_params)

Description: Gets data for this person that is associated with the specified key.

Parameters:

NameTypeDescription
keyStringThe key to get data for; keys are defined in Person.Field (Section 5.3.52)
opt_paramsMap.<opensocial.DataRequest.DataRequestFields|Object>Additional params (Section 5.3.15) to pass to the request.

Returns:

TypeDescription
StringThe data
5.3.51.2.4 getId

Type: {String} getId()

Description: Gets an ID that can be permanently associated with this person.

Returns:

TypeDescription
StringThe ID
5.3.51.2.5 isOwner

Type: {Boolean} isOwner()

Description: Returns true if this person object represents the owner of the current page.

Returns:

TypeDescription
BooleanTrue if this is the owner of the page; otherwise, false
5.3.51.2.6 isViewer

Type: {Boolean} isViewer()

Description: Returns true if this person object represents the currently logged in user.

Returns:

TypeDescription
BooleanTrue if this is the currently logged in user; otherwise, false

5.3.52 opensocial.Person.Field

All of the fields that a person has. These are the supported keys for the Person.getField() (Section 5.3.51.2.3) method.

5.3.52.1 Constructor

opensocial.Person.Field

5.3.52.2 Field Details

5.3.52.2.1 ABOUT_ME

<static> Member of: opensocial.Person.Field.ABOUT_ME

Description: A general statement about the person, specified as a string. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'aboutMe'.

5.3.52.2.2 ACTIVITIES

<static> Member of: opensocial.Person.Field.ACTIVITIES

Description: Person's favorite activities, specified as an Array of strings. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'activities'.

5.3.52.2.3 ADDRESSES

<static> Member of: opensocial.Person.Field.ADDRESSES

Description: Addresses associated with the person, specified as an Array of Address (Section 5.3.4) es. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'addresses'.

5.3.52.2.4 AGE

<static> Member of: opensocial.Person.Field.AGE

Description: Person's age, specified as a number. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'age'.

5.3.52.2.5 BODY_TYPE

<static> Member of: opensocial.Person.Field.BODY_TYPE

Description: Person's body characteristics, specified as an opensocial.BodyType. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'bodyType'.

5.3.52.2.6 BOOKS

<static> Member of: opensocial.Person.Field.BOOKS

Description: Person's favorite books, specified as an Array of strings. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'books'.

5.3.52.2.7 CARS

<static> Member of: opensocial.Person.Field.CARS

Description: Person's favorite cars, specified as an Array of strings. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'cars'.

5.3.52.2.8 CHILDREN

<static> Member of: opensocial.Person.Field.CHILDREN

Description: Description of the person's children, specified as a string. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'children'.

5.3.52.2.9 CURRENT_LOCATION

<static> Member of: opensocial.Person.Field.CURRENT_LOCATION

Description: Person's current location, specified as an Address (Section 5.3.4). Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'currentLocation'.

5.3.52.2.10 DATE_OF_BIRTH

<static> Member of: opensocial.Person.Field.DATE_OF_BIRTH

Description: Person's date of birth, specified as a Date object. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'dateOfBirth'.

5.3.52.2.11 DRINKER

<static> Member of: opensocial.Person.Field.DRINKER

Description: Person's drinking status, specified as an opensocial.Enum with the enum's key referencing opensocial.Enum.Drinker. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'drinker'.

5.3.52.2.12 EMAILS

<static> Member of: opensocial.Person.Field.EMAILS

Description: Emails associated with the person, specified as an Array of Email (Section 5.3.21) s. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'emails'.

5.3.52.2.13 ETHNICITY

<static> Member of: opensocial.Person.Field.ETHNICITY

Description: Person's ethnicity, specified as a string. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'ethnicity'.

5.3.52.2.14 FASHION

<static> Member of: opensocial.Person.Field.FASHION

Description: Person's thoughts on fashion, specified as a string. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'fashion'.

5.3.52.2.15 FOOD

<static> Member of: opensocial.Person.Field.FOOD

Description: Person's favorite food, specified as an Array of strings. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'food'.

5.3.52.2.16 GENDER

<static> Member of: opensocial.Person.Field.GENDER

Description: Person's gender, specified as an opensocial.Enum with the enum's key referencing opensocial.Enum.Gender. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'gender'.

5.3.52.2.17 HAPPIEST_WHEN

<static> Member of: opensocial.Person.Field.HAPPIEST_WHEN

Description: Describes when the person is happiest, specified as a string. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'happiestWhen'.

5.3.52.2.18 HAS_APP

<static> Member of: opensocial.Person.Field.HAS_APP

Description: A boolean indicating whether the person has used the current app. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'hasApp'.

5.3.52.2.19 HEROES

<static> Member of: opensocial.Person.Field.HEROES

Description: Person's favorite heroes, specified as an Array of strings. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'heroes'.

5.3.52.2.20 HUMOR

<static> Member of: opensocial.Person.Field.HUMOR

Description: Person's thoughts on humor, specified as a string. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'humor'.

5.3.52.2.21 ID

<static> Member of: opensocial.Person.Field.ID

Description: A string ID that can be permanently associated with this person. This field may be used interchangeably with the string 'id'. For the anonymous VIEWER, this value MUST be -1.

5.3.52.2.22 INTERESTS

<static> Member of: opensocial.Person.Field.INTERESTS

Description: Person's interests, hobbies or passions, specified as an Array of strings. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'interests'.

5.3.52.2.23 JOB_INTERESTS

<static> Member of: opensocial.Person.Field.JOB_INTERESTS

Description: Person's favorite jobs, or job interests and skills, specified as a string. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'jobInterests'.

5.3.52.2.24 JOBS

<static> Member of: opensocial.Person.Field.JOBS

Description: Jobs the person has held, specified as an Array of Organization (Section 5.3.48) s. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'jobs'.

5.3.52.2.25 LANGUAGES_SPOKEN

<static> Member of: opensocial.Person.Field.LANGUAGES_SPOKEN

Description: List of the languages that the person speaks as ISO 639-1 codes, specified as an Array of strings. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'languagesSpoken'.

5.3.52.2.26 LIVING_ARRANGEMENT

<static> Member of: opensocial.Person.Field.LIVING_ARRANGEMENT

Description: Description of the person's living arrangement, specified as a string. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'livingArrangement'.

5.3.52.2.27 LOOKING_FOR

<static> Member of: opensocial.Person.Field.LOOKING_FOR

Description: Person's statement about who or what they are looking for, or what they are interested in meeting people for. Specified as an Array of opensocial.Enum with the enum's key referencing opensocial.Enum.LookingFor. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'lookingFor'.

5.3.52.2.28 MOVIES

<static> Member of: opensocial.Person.Field.MOVIES

Description: Person's favorite movies, specified as an Array of strings. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'movies'.

5.3.52.2.29 MUSIC

<static> Member of: opensocial.Person.Field.MUSIC

Description: Person's favorite music, specified as an Array of strings. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'music'.

5.3.52.2.30 NAME

<static> Member of: opensocial.Person.Field.NAME

Description: A opensocial.Name object containing the person's name. This field may be used interchangeably with the string 'name'. For the anonymous VIEWER, this value may be a user friendly name such as Guest, Anonymous, depending on the browser locale.

5.3.52.2.31 NETWORK_PRESENCE

<static> Member of: opensocial.Person.Field.NETWORK_PRESENCE

Description: Person's current network status. Specified as an Enum with the enum's key referencing opensocial.Enum.Presence. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'networkPresence'.

5.3.52.2.32 NICKNAME

<static> Member of: opensocial.Person.Field.NICKNAME

Description: A String representing the person's nickname. This represents the casual way to address this person in real life. This field may be used interchangeably with the string 'nickname'. For the anonymous VIEWER, this value may be a user friendly nickname such as Guest, Anonymous, depending on the browser locale.

5.3.52.2.33 PETS

<static> Member of: opensocial.Person.Field.PETS

Description: Description of the person's pets, specified as a string. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'pets'.

5.3.52.2.34 PHONE_NUMBERS

<static> Member of: opensocial.Person.Field.PHONE_NUMBERS

Description: Phone numbers associated with the person, specified as an Array of Phone (Section 5.3.53) s. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'phoneNumbers'.

5.3.52.2.35 POLITICAL_VIEWS

<static> Member of: opensocial.Person.Field.POLITICAL_VIEWS

Description: Person's political views, specified as a string. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'politicalViews'.

5.3.52.2.36 PROFILE_SONG

<static> Member of: opensocial.Person.Field.PROFILE_SONG

Description: Person's profile song, specified as an opensocial.Url. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'profileSong'.

5.3.52.2.37 PROFILE_URL

<static> Member of: opensocial.Person.Field.PROFILE_URL

Description: Person's profile URL, specified as a string. This URL must be fully qualified. Relative URLs will not work in gadgets. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'profileUrl'.

5.3.52.2.38 PROFILE_VIDEO

<static> Member of: opensocial.Person.Field.PROFILE_VIDEO

Description: Person's profile video, specified as an opensocial.Url. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'profileVideo'.

5.3.52.2.39 QUOTES

<static> Member of: opensocial.Person.Field.QUOTES

Description: Person's favorite quotes, specified as an Array of strings. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'quotes'.

5.3.52.2.40 RELATIONSHIP_STATUS

<static> Member of: opensocial.Person.Field.RELATIONSHIP_STATUS

Description: Person's relationship status, specified as a string. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'relationshipStatus'.

5.3.52.2.41 RELIGION

<static> Member of: opensocial.Person.Field.RELIGION

Description: Person's relgion or religious views, specified as a string. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'religion'.

5.3.52.2.42 ROMANCE

<static> Member of: opensocial.Person.Field.ROMANCE

Description: Person's comments about romance, specified as a string. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'romance'.

5.3.52.2.43 SCARED_OF

<static> Member of: opensocial.Person.Field.SCARED_OF

Description: What the person is scared of, specified as a string. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'scaredOf'.

5.3.52.2.44 SCHOOLS

<static> Member of: opensocial.Person.Field.SCHOOLS

Description: Schools the person has attended, specified as an Array of Organization (Section 5.3.48) s. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'schools'.

5.3.52.2.45 SEXUAL_ORIENTATION

<static> Member of: opensocial.Person.Field.SEXUAL_ORIENTATION

Description: Person's sexual orientation, specified as a string. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'sexualOrientation'.

5.3.52.2.46 SMOKER

<static> Member of: opensocial.Person.Field.SMOKER

Description: Person's smoking status, specified as an opensocial.Enum with the enum's key referencing opensocial.Enum.Smoker. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'smoker'.

5.3.52.2.47 SPORTS

<static> Member of: opensocial.Person.Field.SPORTS

Description: Person's favorite sports, specified as an Array of strings. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'sports'.

5.3.52.2.48 STATUS

<static> Member of: opensocial.Person.Field.STATUS

Description: Person's status, headline or shoutout, specified as a string. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'status'.

5.3.52.2.49 TAGS

<static> Member of: opensocial.Person.Field.TAGS

Description: Arbitrary tags about the person, specified as an Array of strings. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'tags'.

5.3.52.2.50 THUMBNAIL_URL

<static> Member of: opensocial.Person.Field.THUMBNAIL_URL

Description: Person's photo thumbnail URL, specified as a string. This URL must be fully qualified. Relative URLs will not work in gadgets. This field may be used interchangeably with the string 'thumbnailUrl'. For the anonymous VIEWER, this value may be a standard representation of an anonymous user on the site.

5.3.52.2.51 TIME_ZONE

<static> Member of: opensocial.Person.Field.TIME_ZONE

Description: Person's time zone, specified as the difference in minutes between Greenwich Mean Time (GMT) and the user's local time. See Date.getTimezoneOffset() in javascript for more details on this format. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'timeZone'.

5.3.52.2.52 TURN_OFFS

<static> Member of: opensocial.Person.Field.TURN_OFFS

Description: Person's turn offs, specified as an Array of strings. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'turnOffs'.

5.3.52.2.53 TURN_ONS

<static> Member of: opensocial.Person.Field.TURN_ONS

Description: Person's turn ons, specified as an Array of strings. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'turnOns'.

5.3.52.2.54 TV_SHOWS

<static> Member of: opensocial.Person.Field.TV_SHOWS

Description: Person's favorite TV shows, specified as an Array of strings. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'tvShows'.

5.3.52.2.55 URLS

<static> Member of: opensocial.Person.Field.URLS

Description: URLs related to the person, their webpages, or feeds. Specified as an Array of opensocial.Url. Container support for this field is OPTIONAL. This field may be used interchangeably with the string 'urls'.

5.3.53 opensocial.Phone

Base interface for all phone objects.

5.3.53.1 Constructor

opensocial.Phone()

5.3.53.2 Method Details

5.3.53.2.1 getField

Type: {String} getField(key, opt_params)

Description: Gets data for this phone that is associated with the specified key.

Parameters:

NameTypeDescription
keyStringThe key to get data for; keys are defined in Phone.Field (Section 5.3.54)
opt_paramsMap.<opensocial.DataRequest.DataRequestFields|Object>Additional params (Section 5.3.15) to pass to the request.

Returns:

TypeDescription
StringThe data

5.3.54 opensocial.Phone.Field

All of the fields that a phone has. These are the supported keys for the Phone.getField() (Section 5.3.53.2.1) method.

5.3.54.1 Constructor

opensocial.Phone.Field

5.3.54.2 Field Details

5.3.54.2.1 NUMBER

<static> Member of: opensocial.Phone.Field.NUMBER

Description: The phone number, specified as a string. This field may be used interchangeably with the string 'number'.

5.3.54.2.2 TYPE

<static> Member of: opensocial.Phone.Field.TYPE

Description: The phone number type or label, specified as a string. Examples: work, my favorite store, my house, etc. This field may be used interchangeably with the string 'type'.

5.3.55 opensocial.ResponseItem

Represents a response that was generated by processing a data request item on the server.

5.3.55.1 Constructor

opensocial.ResponseItem()

5.3.55.2 Method Details

5.3.55.2.1 getData

Type: {Object} getData()

Description: Gets the response data.

Returns:

TypeDescription
ObjectThe requested value calculated by the server; the type of this value is defined by the type of request that was made
5.3.55.2.2 getErrorCode

Type: {String} getErrorCode()

Description: If the request had an error, returns the error code. The error code can be container-specific or one of the values defined by Error (Section 5.3.56).

Returns:

TypeDescription
StringThe error code, or null if no error occurred
5.3.55.2.3 getErrorMessage

Type: {String} getErrorMessage()

Description: If the request had an error, returns the error message.

Returns:

TypeDescription
StringA human-readable description of the error that occurred; can be null, even if an error occurred
5.3.55.2.4 getOriginalDataRequest

Type: {Object} getOriginalDataRequest()

Description: Returns the original data request item.

Returns:

TypeDescription
ObjectThe request item used to fetch this data response
5.3.55.2.5 hadError

Type: {Boolean} hadError()

Description: Returns true if there was an error in fetching this data from the server.

Returns:

TypeDescription
BooleanTrue if there was an error; otherwise, false

5.3.56 opensocial.ResponseItem.Error

Error codes that a response item can return.

5.3.56.1 Constructor

opensocial.ResponseItem.Error

5.3.56.2 Field Details

5.3.56.2.1 BAD_REQUEST

<static> Member of: opensocial.ResponseItem.Error.BAD_REQUEST

Description: The request was invalid. Example: 'max' was -1. This field may be used interchangeably with the string 'badRequest'.

5.3.56.2.2 FORBIDDEN

<static> Member of: opensocial.ResponseItem.Error.FORBIDDEN

Description: The gadget can never have access to the requested data. This field may be used interchangeably with the string 'forbidden'.

5.3.56.2.3 INTERNAL_ERROR

<static> Member of: opensocial.ResponseItem.Error.INTERNAL_ERROR

Description: The request encountered an unexpected condition that prevented it from fulfilling the request. This field may be used interchangeably with the string 'internalError'.

5.3.56.2.4 LIMIT_EXCEEDED

<static> Member of: opensocial.ResponseItem.Error.LIMIT_EXCEEDED

Description: The gadget exceeded a quota on the request. Example quotas include a max number of calls per day, calls per user per day, calls within a certain time period and so forth. This field may be used interchangeably with the string 'limitExceeded'.

5.3.56.2.5 NOT_IMPLEMENTED

<static> Member of: opensocial.ResponseItem.Error.NOT_IMPLEMENTED

Description: This container does not support the request that was made. This field may be used interchangeably with the string 'notImplemented'.

5.3.56.2.6 UNAUTHORIZED

<static> Member of: opensocial.ResponseItem.Error.UNAUTHORIZED

Description: The gadget does not have access to the requested data. To get access, use opensocial.requestPermission() (Section 5.3.1.2.12). This field may be used interchangeably with the string 'unauthorized'.

5.3.57 opensocial.Url

Base interface for all URL objects.

5.3.57.1 Constructor

opensocial.Url()

5.3.57.2 Method Details

5.3.57.2.1 getField

Type: {String} getField(key, opt_params)

Description: Gets data for this URL that is associated with the specified key.

Parameters:

NameTypeDescription
keyStringThe key to get data for; keys are defined in Url.Field (Section 5.3.58)
opt_paramsMap.<opensocial.DataRequest.DataRequestFields|Object>Additional params (Section 5.3.15) to pass to the request.

Returns:

TypeDescription
StringThe data

5.3.58 opensocial.Url.Field

All of the fields that a URL has. These are the supported keys for the Url.getField() (Section 5.3.57.2.1) method.

5.3.58.1 Constructor

opensocial.Url.Field

5.3.58.2 Field Details

5.3.58.2.1 ADDRESS

<static> Member of: opensocial.Url.Field.ADDRESS

Description: The address the URL points to, specified as a string. This field may be used interchangeably with the string 'address'.

5.3.58.2.2 LINK_TEXT

<static> Member of: opensocial.Url.Field.LINK_TEXT

Description: The text of the link, specified as a string. This field may be used interchangeably with the string 'linkText'.

5.3.58.2.3 TYPE

<static> Member of: opensocial.Url.Field.TYPE

Description: The URL number type or label, specified as a string. Examples: work, blog feed, website, etc. This field may be used interchangeably with the string 'type'.

6. References

[RFC2119]Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels" , RFC 2119, March 1997.
[RFC2606]Eastlake, D. and A. Panitz, "Reserved Top Level DNS Names" , RFC 2606, June 1999.
[OpenSocial Data Pipelining]social, o., "OpenSocial Data Pipelining 0.9" , January 2000, <OpenSocial-Data-Pipelining.html>.
[OpenSocial Markup Language Tags]social, o., "OpenSocial Markup Language Tags 0.9" , January 2000, <OpenSocial-Markup-Language-Tags.html>.
[OpenSocial Templating]social, o., "OpenSocial Templating 0.9" , January 2000, <OpenSocial-Templating.html>.
[RESTful Protocol Specification]social, o., "RESTful Protocol Specification 0.9" , January 2000, <REST-API.html>.
[RPC Protocol Specification]social, o., "RPC Protocol Specification 0.9" , January 2000, <RPC-Protocol.html>.
[Gadgets API Specification]social, o., "Gadgets API Specification 0.9" , January 2000, <Gadgets-API-Specification.html>.
[OAuth Core 1.0]Atwood, M., Conlan, R. M., Cook, B., Culver, L., Elliott-McCrea, K., Halff, L., Hammer-Lahav, E., Laurie, B., Messina, C., Panzer, J., Quigley, S., Recordon, D., Sandler, E., Sergent, J., Slesinsky, B., and A. Smith, "OAuth Core 1.0" , December 2007, <http://oauth.net/core/1.0/>.

Author's Address

OpenSocial and Gadgets Specification Group <opensocial-and-gadgets-spec@googlegroups.com>EMail: