opensocial.DataRequest
- メソッド
- 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
メソッド
opensocial.DataRequest.add
add(request, opt_key)
サーバーからデータを取得、もしくは更新するアイテムを追加します。
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
| request | Object | 取得または更新するデータ |
| opt_key | String | 応答データに結びつけるキー |
返り値
なし
サンプル
var req = opensocial.newDataRequest();
req.add(req.newFetchPersonRequest(opensocial.IdSpec.PersonId.VIEWER), "viewer");
opensocial.DataRequest.newFetchActivitiesRequest
サポートされていません。
opensocial.DataRequest.newFetchPeopleRequest
Object newFetchPeopleRequest(idSpec, opt_params)
モバ友の情報を取得するリクエストを作成します。処理時に、Collection
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
| idSpec | opensocial.IdSpec | 取得するモバ友を特定するIdSpec |
| opt_params | Map.<opensocial.DataRequest.PeopleRequestFields | Object> |
返り値
| 型 | 説明 |
|---|---|
| Object | リクエストオブジェクト |
サンプル
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)
アプリケーションデータを取得するリクエストを作成します。処理時に、Map<PersonId, Map<String, Object>> オブジェクトを返します。
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
| idSpec | opensocial.IdSpec | 取得するモバ友を特定するIdSpec |
| keys | Array. | String |
| opt_params | Map.<opensocial.DataRequest.DataRequestFields | Object> |
返り値
| 型 | 説明 |
|---|---|
| Object | リクエストオブジェクト |
サンプル
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)
指定したユーザーのプロフィールを取得するリクエストを作成します。処理時に、 Person オブジェクトを返します。
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
| id | String | 取得するユーザーのID。もしくは VIEWER または OWNER の PersonId |
| opt_params | Map.<opensocial.DataRequest.PeopleRequestFields | Object> |
返り値
| 型 | 説明 |
|---|---|
| Object | リクエストオブジェクト |
サンプル
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)
VIEWER のアプリケーションデータを削除するリクエストを作成します。処理時には何も返しません。
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
| id | String | VIEWER のみ指定可能 |
| keys | Array. | String |
返り値
| 型 | 説明 |
|---|---|
| Object | リクエストオブジェクト |
サンプル
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)
VIEWER のアプリケーションデータを更新するリクエストを作成します。処理時には何も返しません。
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
| id | String | VIEWER のみ指定可能 |
| key | String | データを要求するキー アルファベット(A-Za-z)、数字(0-9)、アンダーバー(_)、ドット(.)、ハイフン(-) を含めることができます |
返り値
| 型 | 説明 |
|---|---|
| Object | リクエストオブジェクト |
サンプル
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)
サーバーにデータリクエストを送信します。
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
| opt_callback | Function | サーバーからレスポンスをパラメータとして呼び出すコールバック関数。 |
返り値
なし
サンプル
req.send(
function(res) {
// ...
}
);
opensocial.DataRequest.DataRequestFields
opensocial.DataRequest.DataRequestFields.ESCAPE_TYPE
opensocial.EscapeTypeのうちから値を指定します。opensocial.EscapeType.HTML_ESCAPEを指定した場合はフィールドがhtmlエスケープされ、opensocial.EscapeType.NONEを指定した場合はエスケープを行いません。
opensocial.DataRequest.FilterType
opensocial.DataRequest.FilterType.ALL
サポートされていません。
opensocial.DataRequest.FilterType.HAS_APP
opensocial.DataRequestFields.FILTERの値として用います。このフィルタを用いた場合、アプリをインストール済みのユーザのデータのみが取得されます。
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
サポートされていません。
opensocial.DataRequest.FilterType.IS_FRIENDS_WITH
サポートされていません。
opensocial.DataRequest.PeopleRequestFields
opensocial.DataRequest.PeopleRequestFields.PROFILE_DETAILS
newFetchPersonRequest, newFetchPeopleRequestなどにおいて、取得するプロフィール情報を指定します。
サンプル
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
サポートされていません。
opensocial.DataRequest.PeopleRequestFields.FILTER
opensocial.DataRequest.FilterTypeのうちから値を指定します。現在は、opensocial.DataRequest.FilterType.HAS_APPのみがサポートされています。
opensocial.DataRequest.PeopleRequestFields.FILTER_OPTIONS
サポートされていません。
opensocial.DataRequest.PeopleRequestFields.FIRST
peopleデータ取得の開始位置を自然数で指定します。通常、opensocial.DataRequest.PeopleRequestFields.MAXと同時に取得するデータのページングに用いられます。デフォルトの値は1です。
以下のサンプルでは取得するpeopleデータを5つずつのページに分けた上で、先頭から3番目のページとなる5人分のデータを取得します。なお、該当するページに指定した数のデータが存在しなかった場合は返せる分だけのデータが取得されます。
サンプル
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
peopleデータ取得の最大数を自然数で指定します。通常、opensocial.DataRequest.PeopleRequestFields.FIRSTと同時に取得するデータのページングに用いられます。デフォルトの値は20です。
opensocial.DataRequest.SortOrder
opensocial.DataRequest.SortOrder.TOP_FRIENDS
サポートされていません。
opensocial.DataRequest.SortOrder.NAME
サポートされていません。
更新履歴
- 2013/03/15
- ドキュメント移行