I am back with the second post in the series. I was part of the IBM Code-a-thon that happened along with IBM Lotusphere 2012 in Mumbai. Me and my colleague Syed were part of the team that created the Social Recruitment application that we proposed. I will write a detailed post on Monday on how we went about it. We actually won the audience vote against the Work Flow engine done by the other team. I am going to present you with one part of the application that we developed during the code-a-thon.

One of the functionalities of the application is to search Linkedin for a particular keyword and list the profiles that matches the keyword. The following code will help you with it that can be used along with any XPages application.

<?xml version=”1.0″ encoding=”UTF-8″?>
<xp:view xmlns:xp=”https://www.ibm.com/xsp/core”>
<!– Maargasystems.com –>
<script type=”text/javascript” src=”https://platform.linkedin.com/in.js”>
api_key:  //need to give that
onLoad: onLinkedInLoad
authorize: true
</script>
<script type=”text/javascript”>
// 2. Runs when the JavaScript framework is loaded
function onLinkedInLoad() {    IN.Event.on(IN, “auth”, onLinkedInAuth);
}

// 2. Runs when the viewer has authenticated
function onLinkedInAuth() {
IN.API.PeopleSearch()
.fields(“firstName”, “lastName”, “positions”)
.params({“keywords”: “Designer”,”count”:25,”start”:25})
.result(displayPeopleSearch)
.error(displayPeopleSearchErrors);
}

// 2. Runs when the PeopleSearch() API call returns successfully
function displayPeopleSearch(peopleSearch) {
peopleSearchDiv = document.getElementById(“peoplesearch”)
var members = peopleSearch.people.values; // people are stored in sa different spot than earlier example
var name;
for (var member in members) {
// but inside the loop, everything is the same
// extract the title from the members first position
name += members[member].firstName + ” ” + members[member].lastName+”,”
peopleSearchDiv.innerHTML += “<table><tr><td></td><td><p>Name: <a>” + members[member].firstName + ” ” + members[member].lastName + ” </a></p><p> ” + members[member].positions.values[0].title + “</p></td></tr></table><hr></hr>”;
}
}

function displayPeopleSearchErrors(error) { /* do nothing */ }
</script>

<br/>

<div id=”peoplesearch”></div>
<br/>

</xp:view>

 

Screenshot

 

 

more similar articles