I'm trying to get person info woth specifies fields:
var params = {};
params[opensocial.DataRequest.PeopleRequestFields.PROFILE_DETAILS] = [
opensocial.Person.Field.NICKNAME,
opensocial.Person.Field.PROFILE_URL,
opensocial.Person.Field.GENDER,
opensocial.Person.Field.THUMBNAIL_URL,
opensocial.Person.Field.ADDRESSES,
opensocial.Person.Field.DATE_OF_BIRTH
];
params[opensocial.IdSpec.Field.USER_ID] = ids;
var idSpec = opensocial.newIdSpec(params);
var req = opensocial.newDataRequest();
req.add(req.newFetchPeopleRequest(idSpec), "profiles");
But on responce, whatever person fields I'm setting up, I always get same set of fields in return:
displayName, id, isOwner, isViewer, nickname, thumbnailUrl
how to get requested fields?
UPD: If this is important, social network I'm working with is yahoo mobage.
You are populating the params
object but you are not actually using it in the request. You are merely using it in the opensocial.newIdSpec()
call which gives you an IdSpec
object. However, if you look at the documentation of the IdSpec
object - this one has only user-related fields, additional data is ignored. You should actually pass in params
in your newFetchPeopleRequest()
call:
req.add(req.newFetchPeopleRequest(idSpec, params), "profiles");
For reference: opensocial.DataRequest.newFetchPeopleRequest
method.