Class Index

Classes


Class 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.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()


Defined in: opensocial.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Method Summary
Method Attributes Method Name and Description
 
add(request, opt_key)
Adds an item to fetch (get) or update (set) data from the server.
 
newFetchActivitiesRequest(idSpec, opt_params)
Creates an item to request an activity stream from the server.
 
newFetchPeopleRequest(idSpec, opt_params)
Creates an item to request friends from the server.
 
newFetchPersonAppDataRequest(idSpec, keys, opt_params)
Creates an item to request app data for the given people.
 
newFetchPersonRequest(id, opt_params)
Creates an item to request a profile for the specified person ID.
 
Deletes the given keys from the datastore for the given person.
 
Creates an item to request an update of an app field for the given person.
 
send(opt_callback)
Sends a data request to the server in order to get a data response.
Class Detail
opensocial.DataRequest()
Method Detail
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

{Object} newFetchActivitiesRequest(idSpec, opt_params)
Creates an item to request an activity stream from the server.

When processed, returns a Collection<Activity>.

Parameters:
{opensocial.IdSpec} idSpec
An IdSpec used to specify which people to fetch. See also IdSpec.
{Map.<opensocial.DataRequest.ActivityRequestFields|Object>} opt_params
Additional parameters to pass to the request; not currently used
Returns:
{Object} A request object

{Object} newFetchPeopleRequest(idSpec, opt_params)
Creates an item to request friends from the server. When processed, returns a Collection <Person> object.
Parameters:
{opensocial.IdSpec} idSpec
An IdSpec used to specify which people to fetch. See also IdSpec.
{Map.<opensocial.DataRequest.PeopleRequestFields|Object>} opt_params
Additional params to pass to the request
Returns:
{Object} A request object

{Object} newFetchPersonAppDataRequest(idSpec, keys, opt_params)
Creates an item to request app data for the given people. When processed, returns a Map< PersonId, Map<String, String>> object. All of the data values returned will be valid json.
Parameters:
{opensocial.IdSpec} idSpec
An IdSpec used to specify which people to fetch. See also IdSpec.
{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"
{Map.<opensocial.DataRequest.DataRequestFields|Object>} opt_params
Additional params to pass to the request
Returns:
{Object} A request object

{Object} 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

{Object} newRemovePersonAppDataRequest(id, keys)
Deletes the given keys from the datastore 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.
{Array.<String> | String} keys
The 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:
{Object} A request object

{Object} 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, must be valid json
Returns:
{Object} A request object

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

Documentation generated by JsDoc Toolkit 2.0.2 on Wed Nov 12 2008 12:32:43 GMT-0800 (PST)