-
Notifications
You must be signed in to change notification settings - Fork 1
/
linkedInPeopleSearch.php
57 lines (47 loc) · 1.91 KB
/
linkedInPeopleSearch.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<html>
<head>
<title>Profile App Example</title>
<script type="text/javascript" src="http://platform.linkedin.com/in.js">
api_key: rbjecyqtr9pn
authorize: true
</script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.5b1.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.7/jquery-ui.min.js"></script>
<script type="text/javascript">
function searchByNameLinkedIn(){
var searchName=document.getElementById("searchTextBoxId").value;
var firstLastName=searchName.split(" ");
alert("First Name: "+firstLastName[0]+" Last Name: "+firstLastName[1]);
IN.API.PeopleSearch()
.fields("firstName", "lastName", "positions")
.params({"first-name": firstLastName[0], "last-name": firstLastName[1]})
.result(displayPeopleSearch)
.error(displayPeopleSearchError);
}
function displayPeopleSearch(peopleSearch) {
var peopleSearchDiv = document.getElementById("peoplesearch");
var members = peopleSearch.people.values; // people are stored in a different spot than earlier example
for (var member in members) {
// but inside the loop, everything is the same
// extract the title from the members first position
peopleSearchDiv.innerHTML += "<p>" + members[member].firstName + " " + members[member].lastName
+ " is a " + members[member].positions.values[0].title + ".</p>";
}
}
function displayPeopleSearchError(error) {
profilesDiv = document.getElementById("peoplesearch");
profilesDiv.innerHTML = "<p>Oops! </p> ERROR:" + error.message;
console.log(error);
}
</script>
</head>
<body>
<form id="searchFormId" name="searchFormName" method="get">
Enter Name: <input id="searchTextBoxId" type="text" name="searchText" />
<input type="button" onClick="searchByNameLinkedIn()" value="Search" />
</form>
<br/>Result<br/>
<div id="peoplesearch"></div>
</body>
</html>