Welcome Developers!

Welcome!

Library: opensocialreference.js
Overview
Interface for containers of people functionality.
  • source: opensocialreference.js
  • desc: Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Constructors
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.
methods
opensocial.Activity()
Base interface for all activity objects.

See also: opensocial.newActivity(), opensocial.requestCreateActivity()

methods
opensocial.Activity.MediaItem()
A media item associated with an activity. Represents images, movies, and audio. Create a MediaItem object using the opensocial.newActivityMediaItem() method.
methods
opensocial.Surface()
Base interface for all surface objects.
methods
opensocial.ResponseItem()
Represents a response that was generated by processing a data request item on the server.
methods
opensocial.Person()
Base interface for all person objects.
methods
opensocial.Environment()
Represents the current environment for a gadget.

See also: opensocial.getEnvironment(),

methods
opensocial.DataResponse()
This object contains the requested server data mapped to the requested keys.

See also: DataRequest

opensocial.DataRequest()

Creates an item 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.DataRequest.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()

methods
  • add(request, opt_key)
Namespaces
opensocial
Namespace for top-level people functions.
methods
opensocial.CreateActivityPriority
The priorities a create activity request can have.

See also: opensocial.requestCreateActivity()

opensocial.Permission
The permissions an app can ask for.

See also: opensocial.hasPermission(), opensocial.requestPermission()

opensocial.ContentRequestParameters
Used by the opensocial.makeRequest() method.
opensocial.ContentRequestParameters.MethodType
opensocial.ContentRequestParameters.ContentType
opensocial.ContentRequestParameters.AuthorizationType
opensocial.Activity.Field
All of the fields that activities can have.

See also: opensocial.Activity.getField()

opensocial.Activity.MediaItem.Type
The possible types of media items.

See also: opensocial.Activity.MediaItem.Field

opensocial.Activity.MediaItem.Field
All of the fields that media items have.

See also: opensocial.Activity.MediaItem.getField()

opensocial.ResponseItem.Error
Error codes that a response item can return.
opensocial.Person.Field
All of the fields that a person has. These are the supported keys for the Person.getField() method.
opensocial.Environment.ObjectType
The types of objects in this container.

See also: Environment.supportsField()

opensocial.DataRequest.PersonId
Constant person IDs available when fetching person information.
opensocial.DataRequest.Group
Groups available when fetching person information.
opensocial.DataRequest.SortOrder
The sort orders available for ordering person objects.
opensocial.DataRequest.FilterType
The filters available for limiting person requests.
opensocial.DataRequest.PeopleRequestFields
opensocial.DataRequest.ActivityRequestFields
Functions
opensocial.requestCreateActivity(activity, priority, opt_callback)
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()

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

parameters
opensocial.Activity activity The activity to create
opensocial.CreateActivityPriority priority The priority for this request
Function opt_callback The function to call once the request has been processed. This callback will either be called or the gadget will be reloaded from scratch
opensocial.hasPermission(permission)
Returns true if the current gadget has access to the specified permission.
parameters
opensocial.Permission permission The permission
returns
Boolean True if the gadget has access for the permission; false if it doesn't
opensocial.requestPermission(permissions, reason, opt_callback)
Requests the member to grant access to the specified permissions.
parameters
Array.<opensocial.Permission> permissions The permissions to request from the viewer
String reason Displayed to the member as the reason why these permissions are needed
Function opt_callback The function to call once the request has been processed; either this callback will be called or the gadget will be reloaded from scratch
opensocial.requestNavigateTo(surface, opt_params)
Attempts to navigate to this gadget on a different surface. If the container supports parameters will pass the optional parameters along to the gadget on the new surface.
parameters
opensocial.Surface surface The surface to navigate to
Map.<String, String> opt_params Params to pass to the gadget after it has been navigated to on the surface
opensocial.getEnvironment()
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
opensocial.Environment The current environment
opensocial.makeRequest(url, callback, opt_params)
Fetches content from the provided URL and feeds that content into the callback function.
parameters
String url The URL where the content is located
Function callback The function to call with the data from the URL once it is fetched
Map.<opensocial.ContentRequestParameters, Object> opt_params Additional parameters to pass to the request
opensocial.newDataRequest()
Creates a data request object to use for sending and fetching data from the server.
returns
opensocial.DataRequest The request object
opensocial.newActivity(title, opt_params)
Creates an activity object, which represents an activity on the server.

See also: requestCreateActivity(),

parameters
String title The title of an activity
Map.<opensocial.Activity.Field, Object> opt_params Any other fields that should be set on the activity object; all of the defined Fields are supported
returns
opensocial.Activity The new activity object
opensocial.newActivityMediaItem(mimeType, url, opt_params)
Creates a media item associated with an activity. Represents images, movies, and audio. Used when creating activities on the server.
parameters
String mimeType MIME type of the media
String url Where the media can be found
Map.<opensocial.Activity.MediaItem.Field, Object> opt_params Any other fields that should be set on the media item object; all of the defined Fields are supported
returns
opensocial.Activity.MediaItem The new media item object
Finds the entry with the given ID value, or returns null if none is found.
parameters
String id The ID to look for
returns
Object? The data
Gets the size of this collection, which is equal to or less than the total size of the result.
returns
Number The size of this collection
Executes the provided function once per member of the collection, with each member in turn as the parameter to the function.
parameters
Function fn The function to call with each collection entry
Returns an array of all the objects in this collection.
returns
Array.<Object> The values in this collection
opensocial.Collection.getTotalSize()
Gets the total size of the larger result set that this collection belongs to.
returns
Number The total size of the result
Gets the offset of this collection within a larger result set.
returns
Number The offset into the total collection
Gets an ID that can be permanently associated with this activity.
returns
String The ID
Gets the activity data that's associated with the specified key.
parameters
String key The key to get data for; see the Field class for possible values
returns
String The data
opensocial.Activity.setField(key, data)
Sets data for this activity associated with the given key.
parameters
String key The key to set data for
String data The data to set
Gets the media item data that's associated with the specified key.
parameters
String key The key to get data for; see the Field class for possible values
returns
String The data
opensocial.Activity.MediaItem.setField(key, data)
Sets data for this media item associated with the given key.
parameters
String key The key to set data for
String data The data to set
Returns the name of this surface.
returns
String The surface name
opensocial.Surface.isPrimaryContent()
Returns true if the gadget is the primary content on this surface. On a canvas page this is most likely true; on a profile page, it is most likely false.
returns
boolean True if the gadget is the primary content; otherwise, false
Returns true if there was an error in fetching this data from the server.
returns
Boolean True if there was an error; otherwise, false
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.
returns
String The error code, or null if no error occurred
opensocial.ResponseItem.getErrorMessage()
If the request had an error, returns the error message.
returns
String A human-readable description of the error that occurred; can be null, even if an error occurred
opensocial.ResponseItem.getOriginalDataRequest()
Returns the original data request.
returns
opensocial.DataRequest The data request used to fetch this data response
Gets the response data.
returns
Object The requested value calculated by the server; the type of this value is defined by the type of request that was made
Gets an ID that can be permanently associated with this person.
returns
String The ID
opensocial.Person.getDisplayName()
Gets a text display name for this person; guaranteed to return a useful string.
returns
String The display name
opensocial.Person.getField(key)
Gets data for this person that is associated with the specified key.
parameters
String key The key to get data for; keys are defined in Person.Field
returns
String The data
Returns true if this person object represents the currently logged in member.
returns
Boolean True if this is the currently logged in member; otherwise, false
Returns true if this person object represents the owner of the current page.
returns
Boolean True if this is the owner of the page; otherwise, false
Returns the current domain — for example, "orkut.com" or "myspace.com".
returns
String The domain
Returns the current surface.
returns
opensocial.Surface The current surface
opensocial.Environment.getSupportedSurfaces()
Returns an array of all the supported surfaces.
returns
Array.<opensocial.Surface> All supported surfaces
Returns the parameters passed into this gadget.
returns
Map.<String, String> The parameter map
opensocial.Environment.supportsField(objectType, fieldName)
Returns true if the specified field is supported in this container on the given object type.
parameters
opensocial.Environment.ObjectType objectType The object type to check for the field
String fieldName The name of the field to check for
returns
Boolean True if the field is supported on the specified object type
opensocial.Environment.hasCapability(functionName)
Returns true if the specified function is supported in this container.
parameters
String functionName The function name
returns
Boolean True if this container supports the function
Returns true if there was an error in fetching this data from the server.
returns
Boolean True if there was an error; otherwise, false
Gets the ResponseItem for the requested field.
parameters

key
returns
opensocial.ResponseItem The requested response calculated by the server
opensocial.DataRequest.add(request, opt_key)
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
Object request Specifies which data to fetch or update
String opt_key A key to map the generated response data to
opensocial.DataRequest.send(opt_callback)
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
Function opt_callback The function to call with the data response generated by the server
opensocial.DataRequest.newFetchPersonRequest(id, opt_params)
Creates an item to request a profile for the specified person ID. When processed, returns a Person object.
parameters
String id The ID of the person to fetch; can be the standard person ID of VIEWER or OWNER
Map.<opensocial.DataRequest.PeopleRequestFields, Object> opt_params Additional parameters to pass to the request; this request supports PROFILE_DETAILS
returns
Object A request object
opensocial.DataRequest.newFetchPeopleRequest(idSpec, opt_params)
Creates an item to request friends from the server. When processed, returns a Collection <Person> object.
parameters
Array.<String>, String idSpec An ID, array of IDs, or a group reference used to specify which people to fetch; the supported keys are VIEWER, OWNER, VIEWER_FRIENDS, OWNER_FRIENDS, or a single ID within one of those groups.
Map.<opensocial.DataRequest.PeopleRequestFields, Object> opt_params Additional params to pass to the request
returns
Object A request object
opensocial.DataRequest.newFetchGlobalAppDataRequest(keys)
Creates an item to request global app data. When processed, returns a Map<String, String> object.
parameters
Array.<String>, String keys The keys you want data for; this can be an array of key names, a single key name, or "*" to mean "all keys"
returns
Object A request object
opensocial.DataRequest.newFetchInstanceAppDataRequest(keys)
Creates an item to request instance app data. When processed, returns a Map<String, String> object.
parameters
Array.<String>, String keys The keys you want data for; this can be an array of key names, a single key name, or "*" to mean "all keys"
returns
Object A request object
opensocial.DataRequest.newUpdateInstanceAppDataRequest(key, value)
Creates an item to request an update of an app instance field from the server. When processed, does not return any data.
parameters
String key The name of the key. This may only contain alphanumeric (A-Za-z0-9) characters, underscore(_), dot(.) or dash(-).
String value The value
returns
Object A request object
opensocial.DataRequest.newFetchPersonAppDataRequest(idSpec, keys)
Creates an item to request app data for the given people. When processed, returns a Map< PersonId, Map<String, String>> object.
parameters
Array.<String>, String idSpec An ID, array of IDs, or a group reference; the supported keys are VIEWER, OWNER, VIEWER_FRIENDS, OWNER_FRIENDS, or a single ID within one of those groups
Array.<String>, String keys The keys you want data for; this can be an array of key names, a single key name, or "*" to mean "all keys"
returns
Object A request object
opensocial.DataRequest.newUpdatePersonAppDataRequest(id, key, value)
Creates an item to request an update of an app field for the given person. When processed, does not return any data.
parameters
String id The ID of the person to update; only the special VIEWER ID is currently allowed.
String key The name of the key. This may only contain alphanumeric (A-Za-z0-9) characters, underscore(_), dot(.) or dash(-).
String value The value
returns
Object A request object
opensocial.DataRequest.newFetchActivitiesRequest(idSpec, opt_params)
Creates an item to request an activity stream from the server.

When processed, returns an object whose "activities" property is a Collection<Activity> object.

parameters
Array.<String>, String idSpec An ID, array of IDs, or a group reference used to specify which people's activities to fetch; the supported keys are VIEWER, OWNER, VIEWER_FRIENDS, OWNER_FRIENDS, or a single ID within one of those groups.
Map.<opensocial.DataRequest.ActivityRequestFields, Object> opt_params Additional parameters to pass to the request
returns
Object A request object
plugin_tamed(obj)
Default taming is to return obj itself. Depending on other taming decisions, it may be more appropriate to return an interposed wrapper.
parameters

obj
Objects
If the activity is of high importance, it will be created even if this requires asking the member for permission. This may cause the container to open a member flow which may navigate away from your gagdet.
If the activity is of low importance, it will not be created if the member has not given permission for the current app to create activities. With this priority, the requestCreateActivity call will never open a member flow.
Access to the viewer person object
opensocial.ContentRequestParameters.opensocial.ContentRequestParameters.METHOD
The method to use when fetching content from the URL; defaults to MethodType.GET. Specified as a MethodType.
opensocial.ContentRequestParameters.opensocial.ContentRequestParameters.CONTENT_TYPE
The type of content that lives at the URL; defaults to ContentType.HTML. Specified as a ContentType.
opensocial.ContentRequestParameters.opensocial.ContentRequestParameters.POST_DATA
The data to send to the URL using the POST method. Specified as a String Defaults to null.
opensocial.ContentRequestParameters.opensocial.ContentRequestParameters.HEADERS
The HTTP headers to send to the URL. Specified as a Map. Defaults to null.
opensocial.ContentRequestParameters.opensocial.ContentRequestParameters.AUTHORIZATION
Specified as an AuthorizationType.
opensocial.ContentRequestParameters.opensocial.ContentRequestParameters.AUTHENTICATION
Specified as an AuthorizationType.
opensocial.ContentRequestParameters.opensocial.ContentRequestParameters.NUM_ENTRIES
If the content is a feed, the number of entries to fetch; defaults to 3. Specified as a Number.
opensocial.ContentRequestParameters.opensocial.ContentRequestParameters.GET_SUMMARIES
If the content is a feed, whether to fetch summaries for that feed; defaults to false. Specified as a Boolean.
opensocial.ContentRequestParameters.MethodType.opensocial.ContentRequestParameters.MethodType.GET
opensocial.ContentRequestParameters.MethodType.opensocial.ContentRequestParameters.MethodType.POST
opensocial.ContentRequestParameters.MethodType.PUT
opensocial.ContentRequestParameters.MethodType.DELETE
opensocial.ContentRequestParameters.MethodType.HEAD
opensocial.ContentRequestParameters.ContentType.opensocial.ContentRequestParameters.ContentType.HTML
Returns text.
opensocial.ContentRequestParameters.ContentType.opensocial.ContentRequestParameters.ContentType.XML
Returns a dom object.
opensocial.ContentRequestParameters.ContentType.opensocial.ContentRequestParameters.ContentType.FEED
Returns a json object.
opensocial.ContentRequestParameters.AuthorizationType.opensocial.ContentRequestParameters.AuthorizationType.NONE
opensocial.ContentRequestParameters.AuthorizationType.opensocial.ContentRequestParameters.AuthorizationType.SIGNED
opensocial.ContentRequestParameters.AuthorizationType.opensocial.ContentRequestParameters.AuthorizationType.AUTHENTICATED
A string ID that can be permanently associated with this activity.
opensocial.Activity.Field.opensocial.Activity.Field.EXTERNAL_ID
A string ID associated with this activity that was generated by the posting app externally.
The string ID of the member who this activity is for.
A string specifying the application that this activity is associated with.
opensocial.Activity.Field.opensocial.Activity.Field.STREAM_TITLE
A string specifing the title of the stream.
opensocial.Activity.Field.opensocial.Activity.Field.STREAM_URL
A string specifying the stream's URL.
opensocial.Activity.Field.opensocial.Activity.Field.STREAM_SOURCE_URL
A string specifying the stream's source URL.
opensocial.Activity.Field.opensocial.Activity.Field.STREAM_FAVICON_URL
A string specifying the URL for the stream's favicon.
A string specifying the title of an activity; the only field that is guaranteed to display when rendering.
A string specifying the full text of an activity.
A string specifying the URL that represents this activity.
opensocial.Activity.Field.opensocial.Activity.Field.MEDIA_ITEMS
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>.
opensocial.Activity.Field.opensocial.Activity.Field.POSTED_TIME
A string specifying the time at which this activity took place in milliseconds since the epoch.
The type of media, specified as a MediaItem.Type object.
opensocial.Activity.MediaItem.Field.opensocial.Activity.MediaItem.Field.MIME_TYPE
The MIME type of media, specified as a String.
A string specifying the URL where the media can be found.
opensocial.ResponseItem.Error.opensocial.ResponseItem.Error.NOT_IMPLEMENTED
This container does not support the request that was made.
opensocial.ResponseItem.Error.opensocial.ResponseItem.Error.UNAUTHORIZED
The gadget does not have access to the requested data. To get access, use opensocial.requestPermission().
opensocial.ResponseItem.Error.opensocial.ResponseItem.Error.FORBIDDEN
The gadget can never have access to the requested data.
opensocial.ResponseItem.Error.opensocial.ResponseItem.Error.BAD_REQUEST
The request was invalid. Example: 'max' was -1.
opensocial.ResponseItem.Error.opensocial.ResponseItem.Error.INTERNAL_ERROR
The request encountered an unexpected condition that prevented it from fulfilling the request.
A string ID that can be permanently associated with this person.
A string containing the person's name.
opensocial.Person.Field.opensocial.Person.Field.THUMBNAIL_URL
Person's photo thumbnail URL, specified as a string.
opensocial.Person.Field.opensocial.Person.Field.PROFILE_URL
Person's profile URL, specified as a string.
Person's age, specified as a number. Not supported by all containers.
Person's gender, specified as a string. Not supported by all containers.
opensocial.Environment.ObjectType.opensocial.Environment.ObjectType.PERSON
opensocial.Environment.ObjectType.opensocial.Environment.ObjectType.ACTIVITY
opensocial.Environment.ObjectType.opensocial.Environment.ObjectType.ACTIVITY_MEDIA_ITEM
opensocial.DataRequest.Group.opensocial.DataRequest.Group.OWNER_FRIENDS
opensocial.DataRequest.Group.opensocial.DataRequest.Group.VIEWER_FRIENDS
opensocial.DataRequest.SortOrder.opensocial.DataRequest.SortOrder.TOP_FRIENDS
When used will sort people by the container's definition of top friends.
When used will sort people alphabetically by the name field.
Retrieves all friends.
opensocial.DataRequest.FilterType.opensocial.DataRequest.FilterType.HAS_APP
Retrieves all friends with any data for this application.
opensocial.DataRequest.PeopleRequestFields.opensocial.DataRequest.PeopleRequestFields.PROFILE_DETAILS
An array of opensocial.Person.Field specifying what profile data to fetch for each of the person objects. The server will always include ID, NAME, and THUMBNAIL_URL.
opensocial.DataRequest.PeopleRequestFields.opensocial.DataRequest.PeopleRequestFields.SORT_ORDER
A sort order for the people objects; defaults to TOP_FRIENDS. Possible values are defined by SortOrder.
opensocial.DataRequest.PeopleRequestFields.opensocial.DataRequest.PeopleRequestFields.FILTER
How to filter the people objects; defaults to ALL. Possible values are defined by FilterType.
opensocial.DataRequest.PeopleRequestFields.opensocial.DataRequest.PeopleRequestFields.FIRST
When paginating, the index of the first item to fetch. Specified as a Number.
opensocial.DataRequest.PeopleRequestFields.opensocial.DataRequest.PeopleRequestFields.MAX
The maximum number of items to fetch; 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. Specified as a Number.
Generated by JsDoc Toolkit 1.4.0 on Mon, 04 Feb 2008 23:41:37 GMT.