-
Notifications
You must be signed in to change notification settings - Fork 1
/
linkedInPeopleSearch2.php
143 lines (128 loc) · 5.47 KB
/
linkedInPeopleSearch2.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>LinkedIn JavaScript API Sample Application</title>
<!-- Load in the JavaScript framework and register a callback function when it's loaded -->
<script type="text/javascript" src="http://platform.linkedin.com/in.js">
api_key: rbjecyqtr9pn
onLoad: onLinkedInLoad
authorize: true
</script>
<script type="text/javascript">
function onLinkedInLoad() {
// Listen for an auth event to occur
IN.Event.on(IN, "auth", onLinkedInAuth);
}
function goToNextPage(id){
alert(id);
location.href = "DisplayProfile.php";
}
function onLinkedInAuth() {
// After they've signed-in, print a form to enable keyword searching
var div = document.getElementById("peopleSearchForm");
div.innerHTML = '<h2>Find People on LinkedIn</h2>';
div.innerHTML += '<form action="javascript:PeopleSearch();">' +
'<input id="keywords" size="30" value="Ashish Chhabria " type="text">' +
'<input type="submit" value="Search!" /></form>';
}
function PeopleSearch(keywords) {
// Call the PeopleSearch API with the viewer's keywords
// Ask for 4 fields to be returned: first name, last name, distance, and Profile URL
// Limit results to 10 and sort by distance
// On success, call displayPeopleSearch(); On failure, do nothing.
var keywords = document.getElementById('keywords').value;
IN.API.PeopleSearch()
.fields("firstName", "id" , "lastName", "distance", "siteStandardProfileRequest"
, "educations", "pictureUrl", "skills", "positions")
.params({"keywords": keywords, "count": 3, "sort": "distance"})
.result(displayPeopleSearch)
.error(function error(e) { document.getElementById("errorField").innerHTML = "<p> Error::: "+ e.message +" </p>"; }
);
}
function displayPeopleSearch(peopleSearch) {
var div = document.getElementById("peopleSearchResults");
div.innerHTML = "<ul>";
// Loop through the people returned
var members = peopleSearch.people.values;
for (var member in members) {
// Look through result to make name
var nameText = members[member].firstName + " " + members[member].lastName;
var id = members[member].id;
// Get the linkedIn Profile URL
// var id = members[member].siteStandardProfileRequest.url;
var url ="DisplayProfile.php";
// Get the degrees of connection
var distance = members[member].distance;
var distanceText = '';
switch (distance) {
case 0: // The viewer
distanceText = "you!"
break;
case 1: // Within three degrees
case 2: // Falling through
case 3: // Keep falling!
distanceText = "a connection " + distance + " degrees away.";
break;
case 100: // Share a group, but nothing else
distanceText = "a fellow group member.";
break;
case -1: // Out of netowrk
default: // Hope we never get this!
distanceText = "far, far, away.";
}
//Get Educations
var educationText = "<br/> Education:: ";
if(members[member].educations != null){
var edus = members[member].educations.values;
for(var edu in edus){
educationText += "<br/>- Degree: " + edus[edu].degree + " at <b>"
+ edus[edu].schoolName + "</b> (" + edus[edu].endDate.year + ")";
}
} else {
educationText += "N/A";
}
// Get the profile image
var profileImageURL = members[member].pictureUrl;
// Get the users skills
var skillsText = "<br/> Skills:: ";
if(members[member].skills != null){
var skills = members[member].skills.values;
for(var skill in skills){
skillsText += "<br/> - Skill: " + skills[skill].proficiency.name + " at "
+ skills[skill].skill.name + " with " + skills[skill].years.name + " years of expierence.";
}
} else {
skillsText += "N/A";
}
// Get the users positions
var positionsText = "<br/> Positions:: ";
if(members[member].positions != null){
var poss = members[member].positions.values;
for(var pos in poss){
positionsText += "<br/> - Worked as " + poss[pos].title + " at <b>"
+ poss[pos].company.name + "</b>";
if(poss[pos].startDate != null){
positionsText += " (" + poss[pos].startDate.month + "/" + poss[pos].startDate.year;
if(poss[pos].endDate != null){
positionsText += " till " + poss[pos].endDate.month + "/" + poss[pos].endDate.year + ")";
} else {
positionsText += " till now)";
}
}
}
} else {
skillsText += "N/A";
}
div.innerHTML += "<li> <img src=\"" + profileImageURL + "\" /> <a href=\"" + url + "?id="+ id+ "\" >" + nameText +
"</a> is " + distanceText + educationText + positionsText + id + "</li><br/>";
}
div.innerHTML += "</ul>";
}onClick="alert(this.name);return false;"
</script>
</head>
<body>
<script type="IN/Login"></script>
<div id="peopleSearchForm"></div>
<div id="peopleSearchResults"></div>
<div id="errorField"></div>
</body>
</html>