In the previous post I have already mentioned about the prerequisite for LinkedIn, here we are going to see how to integrate with XPages
The below script need to be put in a custom Control or in an XPage to load and connect to linkedin, this is used for authentication your application (with the api keys)
Use the below script to connect to LinkedIn
<script type=”text/javascript” src=”https://platform.linkedin.com/in.js”>;api_key: //<Your Linked in API KEY>onLoad: onLinkedInLoadauthorize: true</script>
Now we are going to see how to search and get the profiles from LinkedIn
We are using the div tag to display the search results, and on the loading part of the XPages we are authenticate using the api Keys and running a script to get the details LinkedIn details.
// Authentication Part
<script type=”text/javascript” src=”https://platform.linkedin.com/in.js”;>
api_key: 43XXXXXXif
authentication: true
</script>
//the core code that fetch data and constructing the display model<script type=”text/javascript” >
function loadData() {
peopleSearchDiv = document.getElementById(” peoplesearch”);
var cls = “dataTable”
var imgCell = “imgCell”
var lblCell = “lblCell”
IN.API.PeopleSearch()
.fields(“firstName”, “lastName”, “publicProfileUrl”,”pictureUrl”,”headline”,”industry”)
. params({“keywords”: “Lotus”, “count”: 100, “sort”: “distance”})
.result(function(result) {
profHTML = ” <h4> People search results for keyword ‘Lotus Notes’:</h4>< br></br >”;
for ( var index in result.people.values) {
profile = result.people.values[index]
var position=””
if (profile.pictureUrl) {
profHTML += ” <table class=”+cls+” ><tr>< td rowspan=”+3+” class=”+imgCell+”> “;
profHTML += ” <img src=”+profile.pictureUrl+” /></td>< td class =”+lblCell+”> “;
profHTML +=” <b> Name: </b ></td>< td><a href=” + profile.publicProfileUrl +”> “;
profHTML +=profile.firstName + ” ” + profile.lastName +”</ a></td ><tr>< td>”;
profHTML +=”Designation: </td>< td>”+profile.headline+” </td></ tr><tr ><td> “;
profHTML +=”Industry: </td>< td>”+profile.industry+” </td></ tr></tr ></table> “;}
}
peopleSearchDiv.innerHTML = profHTML;
});
}
</script>
//Div tag that need to display searched values
<div id= “peoplesearch”></div >
//Default call for the LinkedIn to authenticate to show the signin button
<script type=”IN/Login” data-onAuth= “onLinkedInLoad”>
</script>
Leave A Comment