Except as otherwise noted,
the content of this page is licensed under the Creative Commons
Attribution 2.5 License.
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()
add(request, opt_key)
Object
newFetchActivitiesRequest(idSpec, opt_params)
Object
newFetchGlobalAppDataRequest(keys)
Object
newFetchInstanceAppDataRequest(keys)
Object
newFetchPeopleRequest(idSpec, opt_params)
Object
newFetchPersonAppDataRequest(idSpec, keys)
Object
newFetchPersonRequest(id, opt_params)
Object
newUpdateInstanceAppDataRequest(key, value)
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 where "activities" is a Collection<Activity> object.
Array.<String>, String idSpec - An ID, array of IDs, or a group
reference to fetch activities for
Map.<opensocial.DataRequest.ActivityRequestFields, Object> opt_params - Additional
parameters
to pass to the request
Object A request object
Object newFetchGlobalAppDataRequest(keys)
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 newFetchInstanceAppDataRequest(keys)
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 newFetchPeopleRequest(idSpec, opt_params)
Array.<String>, String idSpec - An ID, array of IDs, or a group
reference used to specify which people to fetch
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,
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 newUpdateInstanceAppDataRequest(key, value)
String key - The name of the key
String value - The value
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
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