opensocial.DataRequest
- Method
- opensocial.DataRequest.add
- opensocial.DataRequest.newFetchActivitiesRequest
- opensocial.DataRequest.newFetchPeopleRequest
- opensocial.DataRequest.newFetchPersonAppDataRequest
- opensocial.DataRequest.newFetchPersonRequest
- opensocial.DataRequest.newRemovePersonAppDataRequest
- opensocial.DataRequest.newUpdatePersonAppDataRequest
- opensocial.DataRequest.send
- opensocial.DataRequest.DataRequestFields
- opensocial.DataRequest.FilterType
- opensocial.DataRequest.PeopleRequestFields
- opensocial.DataRequest.PeopleRequestFields.PROFILE_DETAILS
- opensocial.DataRequest.PeopleRequestFields.SORT_ORDER
- opensocial.DataRequest.PeopleRequestFields.FILTER
- opensocial.DataRequest.PeopleRequestFields.FILTER_OPTIONS
- opensocial.DataRequest.PeopleRequestFields.FIRST
- opensocial.DataRequest.PeopleRequestFields.MAX
- opensocial.DataRequest.SortOrder
Method
opensocial.DataRequest.add
add(request, opt_key)
Acquires data from the server or adds items to be updated.
Parameter
| Name | Type | Description |
|---|---|---|
| request | Object | Data to be acquired or updated |
| opt_key | String | Key connected to the response data |
Return value
None
Sample
var req = opensocial.newDataRequest();
req.add(req.newFetchPersonRequest(opensocial.IdSpec.PersonId.VIEWER), "viewer");
opensocial.DataRequest.newFetchActivitiesRequest
Not supported.
opensocial.DataRequest.newFetchPeopleRequest
Object newFetchPeopleRequest(idSpec, opt_params)
Creates a request to acquire Mobatomo (Friend) information. During processing, a Collection Object is returned.
Parameter
| Name | Type | Description |
|---|---|---|
| idSpec | opensocial.IdSpec | IdSpec that identifies the Mobatomo (Friend) to be acquired |
| opt_params | Map.<opensocial.DataRequest.PeopleRequestFields | Object> |
Return value
| Type | Description |
|---|---|
| Object | Request object |
Sample
var params = {};
params[opensocial.IdSpec.Field.USER_ID] = opensocial.IdSpec.PersonId.VIEWER;
params[opensocial.IdSpec.Field.GROUP_ID] = opensocial.IdSpec.GroupId.FRIENDS;
var id_spec = opensocial.newIdSpec(params);
var req = opensocial.newDataRequest();
req.add(req.newFetchPeopleRequest(id_spec), "viewer_friends");
req.send(
function(res) {
var friends = res.get("viewer_friends").getData();
friends.each(function(friend) {
// ...
}
}
);
opensocial.DataRequest.newFetchPersonAppDataRequest
Object newFetchPersonAppDataRequest(idSpec, keys, opt_params)
Creates a request to acquire application data. During processing, a Map<PersonId, Map<String, Object>> object is returned.
Parameter
| Name | Type | Description |
|---|---|---|
| idSpec | opensocial.IdSpec | IdSpec that identifies the Mobatomo to be acquired |
| keys | Array. | String |
| opt_params | Map.<opensocial.DataRequest.DataRequestFields | Object> |
Return value
| Type | Description |
|---|---|
| Object | Request object |
Sample
var params = {};
params[opensocial.IdSpec.Field.USER_ID] = opensocial.IdSpec.PersonId.VIEWER;
params[opensocial.IdSpec.Field.GROUP_ID] = "FRIENDS";
var idSpec = opensocial.newIdSpec(params);
var req = opensocial.newDataRequest();
req.add(req.newFetchPersonAppDataRequest(idSpec, ["score"]), "friends_score");
req.send(
function(res) {
var friends_score = data.get("friends_score").getData();
for (var id in friends_score) {
var score = friends_score[id]["score"];
// ...
}
}
);
opensocial.DataRequest.newFetchPersonRequest
Object newFetchPersonRequest(id, opt_params)
Creates a request to acquire the profile of the specified user. During processing, a Person object is returned.
Parameter
| Name | Type | Description |
|---|---|---|
| id | String | The user ID to be acquired, or the VIEWER or OWNER PersonID |
| opt_params | Map.<opensocial.DataRequest.PeopleRequestFields | Object> |
Return value
| Type | Description |
|---|---|
| Object | Request object |
Sample
var req = opensocial.newDataRequest();
req.add(req.newFetchPersonRequest(opensocial.IdSpec.PersonId.VIEWER), "viewer");
req.send(
function(res) {
var score = res.get("score").getData();
// ...
}
);
opensocial.DataRequest.newRemovePersonAppDataRequest
Object newRemovePersonAppDataRequest(id, keys)
Creates a request to delete VIEWER application data. During processing, nothing is returned.
Parameter
| Name | Type | Description |
|---|---|---|
| id | String | Only VIEWER can be specified |
| keys | Array. | String |
Return value
| Type | Description |
|---|---|
| Object | Request object |
Sample
var params = {};
var req = opensocial.newDataRequest();
req.add(req.newRemovePersonAppDataRequest(opensocial.IdSpec.PersonId.VIEWER, ["score"]), "score");
req.send(
function(res) {
// ...
}
);
opensocial.DataRequest.newUpdatePersonAppDataRequest
Object newUpdatePersonAppDataRequest(id, keys, value)
Creates a request to update VIEWER application data. Processing, nothing is returned.
Parameter
| Name | Type | Description |
|---|---|---|
| id | String | Only VIEWER can be specified. |
| key | String | Key for requesting data. Alphabetical characters (A-Z, a-z), numerical characters (0-9), underscores (_), periods (.), and hyphens (-) may be included. |
Return value
| Type | Description |
|---|---|
| Object | Request object |
Sample
var params = {};
var req = opensocial.newDataRequest();
req.add(req.newUpdatePersonAppDataRequest(opensocial.IdSpec.PersonId.VIEWER, "score", 1000), "viewer_score");
req.send(
function(res) {
var score = res.get("viewer_score").getData();
// ...
}
);
opensocial.DataRequest.send
send(opt_callback)
Sends a data request to the server.
Parameter
| Name | Type | Description |
|---|---|---|
| opt_callback | Function | The callback function that calls the response from the server as a parameter. |
Return value
None
Sample
req.send(
function(res) {
// ...
}
);
opensocial.DataRequest.DataRequestFields
opensocial.DataRequest.DataRequestFields.ESCAPE_TYPE
Not supported.
opensocial.DataRequest.FilterType
opensocial.DataRequest.FilterType.ALL
Not supported.
opensocial.DataRequest.FilterType.HAS_APP
This is used as an opensocial.DataRequestFields.FILTER value. When this filter is applied, only the data of users who have installed the application will be acquired.
Sample
var params = {};
params[opensocial.DataRequest.PeopleRequestFields.FILTER] = opensocial.DataRequest.FilterType.HAS_APP;
var req = opensocial.newDataRequest();
req.add(req.newFetchPeopleRequest(idSpec, params), "people");
req.send(callback);
opensocial.DataRequest.FilterType.TOP_FRIENDS
Not supported.
opensocial.DataRequest.FilterType.IS_FRIENDS_WITH
Not supported.
opensocial.DataRequest.PeopleRequestFields
opensocial.DataRequest.PeopleRequestFields.PROFILE_DETAILS
It assigns the profile information to be acquired in newFetchPersonRequest, newFetchPeopleRequest, and so on.
Sample
var params = {};
params[opensocial.DataRequest.PeopleRequestFields.PROFILE_DETAILS] = [
mbga.Person.Field.JOB_TYPE, //mbga original
mbga.Person.Field.BLOOD_TYPE, //mbga original
opensocial.Person.Field.NICKNAME,
opensocial.Person.Field.ABOUT_ME,
opensocial.Person.Field.DATE_OF_BIRTH,
opensocial.Person.Field.INTERESTS,
opensocial.Person.Field.PROFILE_URL,
opensocial.Person.Field.THUMBNAIL_URL,
opensocial.Person.Field.GENDER,
opensocial.Person.Field.HAS_APP,
];
var req = opensocial.newDataRequest();
req.add(req.newFetchPeopleRequest(idSpec, params), "people");
req.send(callback);
opensocial.DataRequest.PeopleRequestFields.SORT_ORDER
Not supported.
opensocial.DataRequest.PeopleRequestFields.FILTER
A value is assigned from opensocial.DataRequest.FilterType. Currently, only opensocial.DataRequest.FilterType.HAS_APP is supported.
opensocial.DataRequest.PeopleRequestFields.FILTER_OPTIONS
Not supported.
opensocial.DataRequest.PeopleRequestFields.FIRST
The starting position of people data acquisition is assigned using natural numbers. Normally, it is used for paging data that is acquired at the same time as opensocial.DataRequest.PeopleRequestFields.MAX. The default value is 1.
In the following sample, the people data to be acquired is first split into 5 per page, and then the data of the 5 people on the third page from the top is acquired. If the assigned number of data units does not exist on the pertinent page, just enough data is acquired so that it can be returned.
Sample
var params = {};
params[opensocial.DataRequest.PeopleRequestFields.MAX] = 5;
params[opensocial.DataRequest.PeopleRequestFields.FIRST] = 3;
var req = opensocial.newDataRequest();
req.add(req.newFetchPeopleRequest(idSpec, params), "people");
req.send(callback);
opensocial.DataRequest.PeopleRequestFields.MAX
The maximum number of people data acquisitions is assigned using natural numbers. Normally, it is used for paging data that is acquired at the same time as opensocial.DataRequest.PeopleRequestFields.FIRST. The default value is 20.
opensocial.DataRequest.SortOrder
opensocial.DataRequest.SortOrder.TOP_FRIENDS
Not supported.
opensocial.DataRequest.SortOrder.NAME
Not supported.
Revision History
- 12/2010
- Initial Release.