bannerColor WARNING_YELLOW templateName stackForums

IN.API.Profile()

Profile

IN.API.Profile(ids).fields(fields).result(resultCallback)
IN.API.Profile().ids(id1, id2, id3).fields(field1, field2, field3).result(resultCallback)
IN.API.Profile().ids([id1, id2]).fields([field1, field2]).result(resultCallback)

  • default ids() - Array {String}, Argument List {String} 
    Specifies the IDs to retrieve
  • fields() (optional) - Array {String}, Argument List {String} 
    Specifies the fields to retrieve. If not specified, the default fields will be used: "id", "firstName", "lastName", "headline", "pictureUrl".  A full list of available fields can be found in Profile Fields.

Examples

Console Examples

There are a few interactive console examples which you can play with to understand the profile call:

http://bit.ly/gVri2k, http://bit.ly/ewxtfy, http://bit.ly/i1qRwz

Basic Example

IN.API.Profile("me").(result(doMyThing))

No fields are included, so the results include the standard fields (currently headline, id, firstName, lastName,, location, siteStandardProfileRequest, apiStandardProfileRequest, pictureUrl, url, industry). An example result would then be a Javascript object which is a list of person objects.  An example of the person object looks like this:

   "headline":"President of the United States",

   "id":"NhZXBl_O6f",

   "lastName":"Obama",

   "pictureUrl":"http://media.linkedin.com/mpr/mprx/0_fsPnURNRhLhk_Ue2fjKLUZkB2FL6TOe2S4bdUZz61GA9Ysxu_y_sz4THGW5JGJWhaMleN0F61-Dg",

   "location":{

       "name":"Washington, DC","country":{"code":"us"}

   },

   "siteStandardProfileRequest":{

      "url":"http://www.linkedin.com/profile?viewProfile=&key=11554268&authToken=3KMh&authType=name&trk=api*a124520*s132954*"

   },

   "apiStandardProfileRequest":{

      "headers":{

         "values":[{

            "name":"x-li-auth-token",

            "value":"name:3KMh"}

         ],"_total":1},

      "url":"http://api.linkedin.com/v1/people/NhZXBl_O6f"

    },

    "industry":"Executive Branch",

    "firstName":"Barack"

}

Specific Fields

The Profile call supports a .fields() method which allows you to specify which fields you want returned, instead of just getting the default fields. If youwant to understand what fields are available for each person, see the Profile Fields documentation, as well as the Field Selector information to understand how to express your request correctly.

>IN.API.Profile("12345")
    .fields(["firstName","headline"])
    .result(function(result) {
       alert JSON.stringify(result)) 
    }

In this example we're asking for two specific fields (once you start specifying Profile Fields, your return is limited to just the fields you have asked for.  The defaults are overriden entirely.  In addition, instead of calling a separate function, an inline function has been created for the results.  The results for this case would be much smaller, and the results would be shown in an alert window to the user.

{  
"headline":"President of the United States",
   "firstName":"Barack"

}

Field Selectors

When selecting fields for a profile, it's possible to extend the search to get specific sub-fields. For instance, if you want to see the user's positions, you can ask for those.  But you can also ask for the company name by using Field Selectors like so:
  IN.API.Profile("me")
    .fields(["firstName","headline","positions:(company)"])
    .result(function(result) {
       alert (JSON.stringify(result))
    })