OpenSocial/spec

newFetchPersonRequest with a String ID as parameter results in unexpected error

mmarum-sugarcrm opened this issue · 1 comments

Original author: mraj...@gmail.com (August 27, 2008 10:23:57)

Description of the bug/feature
==================================
Requesting a person's data by passing an ID number results in a Unexpected
error

What steps will reproduce the problem?
======================================

  1. Make a request in the form of
    req.add(req.newFetchPersonAppDataRequest('XXXXXXXXXX'), 'aPerson');
    Where XXXXXXXXXX is the user id number
    2.
    3.

Which container (orkut, MySpace, hi5, etc) are you using?
=========================================================
orkut

Which browsers have you experienced this on?
============================================
ff

Please provide any additional information below.

I am still not able to get person's data from person id.

Sample Code:
function getData()
{
var req = opensocial.newDataRequest();
req.add(req.newFetchPersonRequest('4041920253253596426','*'), 'person');
req.send(fetchPersonHandler);
}

function fetchPersonHandler(resp) {
if (!resp.hadError()) { 
var person = resp.get('person').getData(); 
alert(person.getDisplayName());
}
else
{
alert(resp.hadError());
}

This code returns,
hadErrror = true
ErrorCode = 500
ErrorMessage = Unexpected error

Original issue: http://code.google.com/p/opensocial-resources/issues/detail?id=312

From api.kurrik%google.com@gtempaccount.com on August 27, 2008 21:02:58
The sample you provided is invalid. The second parameter of newFetchPersonRequest
should be a parameter object, not "*".

The following sample will list your friends. Clicking on their name will attempt to
fetch the user's data. On orkut, if the user does not have the app installed, you
will see an "unauthorized" error.

function onPersonGot(result) {
var response = result.get("person");
if (response.hadError()) {
output("There was a problem fetching this user: " +
response.getErrorCode());
} else {
output("Fetched " +
result.get("person").getData().getDisplayName());
}
};

function closeGetPerson(id) {
return function() {
var params = {};
var req = opensocial.newDataRequest();
req.add(req.newFetchPersonRequest(id, params), "person");
req.send(onPersonGot);
};
};

function closePrintFriend(list) {
return function(friend) {
var item = document.createElement("li");
var link = document.createElement("a");
var text = document.createTextNode(friend.getDisplayName());
list.appendChild(item);
item.appendChild(link);
link.appendChild(text);
link.onclick = closeGetPerson(friend.getId());
link.href = "javascript:void(0);";
};
};

function gotFriends(data) {
var friends = data.get("of").getData();
var list = document.createElement("ul");
var main = document.getElementById("dom_handle")
main.innerHTML = "";
main.appendChild(list);
friends.each(closePrintFriend(list));
};

function getFriends() {
var params = {};
params[opensocial.DataRequest.PeopleRequestFields.MAX] = 1000;
var req = opensocial.newDataRequest();
req.add(req.newFetchPeopleRequest(
opensocial.DataRequest.Group.OWNER_FRIENDS, params), "of");
req.send(gotFriends);
};

getFriends();