Except as otherwise noted,
the content of this page is licensed under the Creative Commons
Attribution 3.0 License.
Google Code offered in: English - Español - 日本語 - 한국어 - Português - Pусский - 中文(简体) - 中文(繁體)
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()
add(request, opt_key)
Object
newFetchActivitiesRequest(idSpec, opt_params)
Object
newFetchPeopleRequest(idSpec, opt_params)
Object
newFetchPersonAppDataRequest(idSpec, keys)
Object
newFetchPersonRequest(id, opt_params)
Object
newUpdatePersonAppDataRequest(id, key, value)
send(opt_callback)
add(request, opt_key)
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)
When processed, returns an object whose "activities" property is a Collection<Activity> object.
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; not currently used
Object A request object
Object newFetchPeopleRequest(idSpec, opt_params)
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
Object A request object
Object newFetchPersonAppDataRequest(idSpec, keys)
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"
Object A request object
Object newFetchPersonRequest(id, opt_params)
Person object.
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
Object A request object
Object newUpdatePersonAppDataRequest(id, key, value)
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
Object A request object
send(opt_callback)
Function opt_callback - The function to call with the
data response
generated by the server