Up to my last post, we have created our app on LinkedIn and able to authorize it. Now, time to hit APIs and get data.
In this post, we will try to understand about LinkedIn PeopleSearch API. This is how it looks like…
IN.API.PeopleSearch() .params({"first-name":"Barack"}) .fields(["firstName","headline"]) .result(function(result) { alert JSON.stringify(result)) }
- fields() (optional) – Array {String}, Argument List {String}
Specifies the fields to retrieve based on the Profile API. If not specified, the default fields from the server will be used, subject to change. A full list of available fields can be found in Profile Fields. - params() (optional) – Object
The key/value pairs to use as parameters for the search. A full list of parameters is available in the People Search API documentation.
And in result, we will get a Json/javascript object with all fields we specified or some default fields if nothing specified.
For example, below line will provide given Javascript objects. We need to traverse it and read it.
IN.API.PeopleSearch().params({"first-name":"Barack"}).result(doMyThing)
An example result would then be a Javascript object which is a list of person objects, 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" }
LinkedIn provides a great documentation on their APIs. So, don’t worry if you are not getting much from this post.
Check here, you will get a interactive example to play with.
Below are the sample PM/PR files, use this for reference purpose only.
Sample Presentation Model JS File
Sample Physical Renderer JS File
Hope this will help someone in need.
[su_divider]
@AskmeSiebel