opensocial newFetchPeopleRequest忽略参数

时间:2014-07-18 08:49:24

标签: javascript opensocial

我试图获取人员信息,并指定字段:

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");

但是在回答时,无论我设置的是哪个人,我都会得到相同的字段作为回报:

  

displayName,id,isOwner,isViewer,nickname,thumbnailUrl

如何获取请求的字段?

UPD: 如果这很重要,我与之合作的社交网络就是yahoo mobage。

1 个答案:

答案 0 :(得分:2)

您正在填充params对象,但实际上您并未在请求中使用它。您只是在opensocial.newIdSpec()调用中使用它,它会为您提供IdSpec个对象。但是,如果查看documentation of the IdSpec object - 这个只有用户相关字段,则会忽略其他数据。您实际上应该在params电话中传递newFetchPeopleRequest()

 req.add(req.newFetchPeopleRequest(idSpec, params), "profiles");

供参考:opensocial.DataRequest.newFetchPeopleRequest method