Frog Developer Platform

users.getInfo

11:39AM Aug 24th
0
*

Returns user informations for any numbers of users specified by ID or username. Only available as a GET request.

Roles

  • api.users.getinfo
  • user.view.skeleton
  • user.image.view (to request user images)
  • user.status.view (to request statuses)
  • self.status.view (to view the user's own status)
  • group.view.all (to request all groups)
  • group.view.self (to request groups they are a member of)

 

Parameters

id

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

username

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

details

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:

  • dob : includes the users date of birth
  • image : includes the URL of the users profile picture
  • status : latest user status
  • groups : get details about the groups each member belongs to
  • 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.

Example Return Data

"data":[
        {
         "id":"3",
         "username":"user-4c762d19ca527",
         "firstname":"Test",
         "surname":"User",
         "profile":{
                    "id":"3",
                    "name":"profile-4c762d19ca90d"
                   },
         "company":{
                    "id":"5",
                    "key":"c073dqk9lmo0g8sokc0s44wss",
                    "name":"Test Company"
                   }
        }
       ]

Example Return Data (with status)

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"
       ]

Notes

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.*

7 Comments

5:48PM Jul 27th
0

Think it should be "var profile=data[i].profile.name" :)

Regards

Paul

12:35PM Jul 27th
12:31PM Jul 27th
0

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

10:59AM May 24th
0

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"
      }
});
10:01PM Apr 12th
0

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});
6:30PM Apr 02nd
0

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});
10:02AM Jan 18th
0

When "groups" is requested, a list of objects is returned but it is not specified how to retrieve useful information from these objects.

I get this as well [object, Object],[object, Object] is returned for groups for a user. I'm trying to get a list of the groups that the logged on user is part of then grab a list of the other users; to create a random name for starter activities like nine stiles had at the show - Danny Park
Hi Danny, did you get anywhere with this? I am trying to do a similar thing but can't work out how to do it. - Tom Wake
Ask a Question
Widget code generator
Watch our FDP Screencasts
Download our FDP Cheat Sheet

Badges

We've introduced badges to the FDP, get involved to open up more badges.

  • gold cup badge 500+ points
  • silver cup badge101-499 points
  • red rosette badge51-100 points
  • green rosette badge6-50 points
  • blue rosette badge0-5 points

FDP Support

This site should become your first port of call for all things FDP. If you have feedback or would like to see additional services on this site please contact us on fdp@frogtrade.com

a Frog site