Returns user informations for any numbers of users specified by ID or username. Only available as a GET request.
A single (int) or set of comma-separated (int)s of the user IDs to look up. e.g. id=34 or id=34,56,45
A single (string) or set of comma-separated (string)s of the user usernames to look up. e.g. username=joeblogs or username=joeblogs,emilywall,fredperry
By default only the core user data will be returned for each user specified. You can request extra data using keywords in the details parameter. The keywords available are:
upn : the students UPN
e.g. details=dob means the response will include the users dob. details=dob,image means the response will include the users dob and profile picture URL.
"data":[
{
"id":"3",
"username":"user-4c762d19ca527",
"firstname":"Test",
"surname":"User",
"profile":{
"id":"3",
"name":"profile-4c762d19ca90d"
},
"company":{
"id":"5",
"key":"c073dqk9lmo0g8sokc0s44wss",
"name":"Test Company"
}
}
]
When requesting status, the function returns an additional status object containing the text and time time:
"data":[
{
"id":"3",
"username":"user-4c762d19ca527",
"firstname":"Test",
"surname":"User",
"profile":{
"id":"3",
"name":"profile-4c762d19ca90d"
},
"company":{
"id":"5",
"key":"c073dqk9lmo0g8sokc0s44wss",
"name":"Test Company"
}
}
"status":{
"text":"Hello, this is my status"
"time":"2011-07-08T11:18:21.431-0100"
]
This method will always return an array of users, even if only one is returned. This is to allow re-use of display elements across widgets/purposes, and allow correct functionality when only a single contact is matched from a comma-seperated request set.*
Think it should be "var profile=data[i].profile.name" :)
Regards
Paul
Can someone help, I would like to get the login profile of the user
for (var i=0; i<data.length; i++) {
var id = data[i].id
var profile = data[i].profile
}
Frog.API.get('users.search',{'params': {'id':id,"details": "image,profile"},'onSuccess': setCurrentUser});
Which I thought would work, but doesn't. Is there another way?.
Cheers
Here is a widget I've put together, that iterates over all the members of a return from users.getInfo. Hope it helps you out.
We iterate over data (for var i in data) so that if more than one user's information is returned, it can do the same thing for each user object that is returned.
The "typeof" call in javascript is very useful - and the reason we check against this for this particular return is because an object can not only have member strings (text), or nested objects, it can also have native functions as members, and we should be wary of this.
widget.onLoad = function() {
var user = UWA.Environment.user;
var addItem = function(key, value) {
key = key.join(".");
return "<li>" + key + ": " + value + "</li>";
};
Frog.API.get('users.getInfo', {
onSuccess: function(data) {
var h = "<ol>";
for(var i in data) {
if(typeof data[i] === "string") {
h += addItem(i, data[i]);
} else if(typeof data[i] === "object") {
for(var j in data[i]) {
if(typeof data[i][j] === "string") {
h += addItem([i, j], data[i][j]);
} else if(typeof data[i][j] === "object") {
for(var k in data[i][j]) {
if(typeof data[i][j][k] === "string") {
h += addItem([i, j, k], data[i][j][k]);
} // we could go on forever...
}
}
}
}
}
h += "</ol>";
widget.body.setHTML(h);
},
onError: function(error) {
alert(error.message);
},
params: {
id: user.id,
details: "dob,image,status,groups"
}
});
solved it, to avoid [object, object] you need data[p].groups to be broken down into seperate elements just like an array.
The code below worked for me displaying all the groups names the user is a member of.
var setCurrentUser= function(data){
var p=0;
var i=0;
for (p=0;p<data.length;p++) {
var txt = data[p].firstname+' '+data[p].surname+' is a member of <p>';
widget.addBody(txt);
for (i=0;i<data[p].groups.length;i++) {
var grp=data[p].groups[i];
widget.addBody(grp.name);
}};}
Frog.API.get('users.search',{'params': {'surname':'Morgan',"details": "status,image,dob,groups"},'onSuccess': setCurrentUser});
I'm trying this, but I'm getting object, Object too
var setCurrentUser= function(data){
var p=0;
for (p=0;p<data.length;p++) {var txt = data[p].firstname+' '+data[p].surname+' is a member of
'+data[p].groups+'<p>';document.write(txt);};}
Frog.API.get('users.search',{'params': {'surname':'Morgan',"details": "status,image,dob,groups"},'onSuccess': setCurrentUser});
When "groups" is requested, a list of objects is returned but it is not specified how to retrieve useful information from these objects.
