Skip to content

Instantly share code, notes, and snippets.

@jakobo
Created October 14, 2010 22:24
Show Gist options
  • Save jakobo/627203 to your computer and use it in GitHub Desktop.
Save jakobo/627203 to your computer and use it in GitHub Desktop.
<!DOCTYPE>
<html>
<head>
<title>LinkedIn JavaScript API</title>
<script type="text/javascript" src="http://platform.linkedin.com/in.js">
api_key: OugQK-Y27TUS2_LeCD_vLuUE0L9ew35dh-tYtWkZDk4lQm6LYbcdVXgRELNWUMxl
authorize: false
</script>
</head>
<body>
<script type="IN/Login">Logged in as <?js= firstName ?> <?js= lastName ?></script>
</body>
</html>
<!DOCTYPE>
<html>
<head>
<title>LinkedIn JavaScript API</title>
<script type="text/javascript" src="http://platform.linkedin.com/in.js">
api_key: OugQK-Y27TUS2_LeCD_vLuUE0L9ew35dh-tYtWkZDk4lQm6LYbcdVXgRELNWUMxl
authorize: false
</script>
<script type="text/javascript">
function getProfile() {
IN.API.Profile("url=http://www.linkedin.com/in/jakobheuser")
.fields("firstName", "lastName", "industry", "distance", "summary")
.result(function(res) {
var user = res.values[0],
tmpl = "<p>{firstName} {lastName} works in the {industry} industry. You are {distance} degree(s) away in the network with \"-1\" meaning out-of-network. What follows is their summary.</p><p>{summary}</p>";
for (var name in user) {
tmpl = tmpl.replace(new RegExp("{"+name+"}", "g"), user[name]);
}
document.getElementById("profile").innerHTML = tmpl;
})
.error(function(err) {
document.getElementById("profile").innerHTML = "Error getting data: "+err.message;
});
}
</script>
</head>
<body>
<script type="IN/Login" data-onAuth="getProfile">Logged in as <?js= firstName ?> <?js= lastName ?></script>
<hr/>
This is the profile for the user at URL "http://www.linkedin.com/in/jakobheuser" (based on his public profile URL). It becomes available on "Sign in"
<div id="profile"></div>
</body>
</html>
<!DOCTYPE>
<html>
<head>
<title>LinkedIn JavaScript API</title>
<script type="text/javascript" src="http://platform.linkedin.com/in.js">
api_key: OugQK-Y27TUS2_LeCD_vLuUE0L9ew35dh-tYtWkZDk4lQm6LYbcdVXgRELNWUMxl
authorize: false
</script>
<script type="text/javascript">
function getProfile() {
IN.API.Profile("url=http://www.linkedin.com/in/jakobheuser")
.fields("firstName", "lastName", "industry", "distance", "summary")
.result(function(res) {
var user = res.values[0],
tmpl = "<p>{firstName} {lastName} works in the {industry} industry. You are {distance} degree(s) away in the network with \"-1\" meaning out-of-network. What follows is their summary.</p><p>{summary}";
for (var name in user) {
tmpl = tmpl.replace(new RegExp("{"+name+"}", "g"), user[name]);
}
document.getElementById("profile").innerHTML = tmpl;
})
.error(function(err) {
document.getElementById("profile").innerHTML = "Error getting data: "+err.message;
});
}
function getConnections() {
IN.API.Connections("me")
.fields("firstName", "lastName", "pictureUrl", "publicProfileUrl")
.result(function(res) {
var users = [],
total = res._total,
values = res.values,
output = "",
tmpl = "<li style=\"float: left;\"><a href=\"{publicProfileUrl}\"><img src=\"{pictureUrl}\" alt=\"{firstName} {lastName}\"/></a></li>";
for (var i = 0, len = values.length; i < len && users.length <= 10; i++) {
var connection = values[i];
if (!connection.pictureUrl) {
continue;
}
users.push(connection);
}
for (var i = 0, len = users.length; i < len; i++) {
var user = users[i],
tmplCopy = tmpl;
for (var name in user) {
tmplCopy = tmplCopy.replace(new RegExp("{"+name+"}", "g"), user[name]);
}
output += tmplCopy;
}
document.getElementById("photos").innerHTML = "<ul>"+output+"</ul><div style=\"clear:both;\"></div>";
})
.error(function(err) {
document.getElementById("photos").innerHTML = "Error getting data: "+err.message;
})
}
</script>
</head>
<body>
<script type="IN/Login" data-onAuth="getProfile, getConnections">Logged in as <?js= firstName ?> <?js= lastName ?></script>
<hr/>
This is the profile for the user at URL "http://www.linkedin.com/in/jakobheuser" (based on his public profile URL). It becomes available on "Sign in"
<div id="profile"></div>
<hr/>
These are some of your connection's photos:
<div id="photos">Log In to see this data.</div>
</body>
</html>
<!DOCTYPE>
<html>
<head>
<title>LinkedIn JavaScript API</title>
<script type="text/javascript" src="http://platform.linkedin.com/in.js">
api_key: OugQK-Y27TUS2_LeCD_vLuUE0L9ew35dh-tYtWkZDk4lQm6LYbcdVXgRELNWUMxl
authorize: false
</script>
<script type="text/javascript">
function getProfile() {
IN.API.Profile("url=http://www.linkedin.com/in/jakobheuser")
.fields("firstName", "lastName", "industry", "distance", "summary")
.result(function(res) {
var user = res.values[0],
tmpl = "<p>{firstName} {lastName} works in the {industry} industry. You are {distance} degree(s) away in the network with \"-1\" meaning out-of-network. What follows is their summary.</p><p>{summary}";
for (var name in user) {
tmpl = tmpl.replace(new RegExp("{"+name+"}", "g"), user[name]);
}
document.getElementById("profile").innerHTML = tmpl;
})
.error(function(err) {
document.getElementById("profile").innerHTML = "Error getting data: "+err.message;
});
}
function getConnections() {
IN.API.Connections("me")
.fields("firstName", "lastName", "pictureUrl", "publicProfileUrl")
.result(function(res) {
var users = [],
total = res._total,
values = res.values,
output = "",
tmpl = "<li style=\"float: left;\"><a href=\"{publicProfileUrl}\"><img src=\"{pictureUrl}\" alt=\"{firstName} {lastName}\"/></a></li>";
for (var i = 0, len = values.length; i < len && users.length <= 10; i++) {
var connection = values[i];
if (!connection.pictureUrl) {
continue;
}
users.push(connection);
}
for (var i = 0, len = users.length; i < len; i++) {
var user = users[i],
tmplCopy = tmpl;
for (var name in user) {
tmplCopy = tmplCopy.replace(new RegExp("{"+name+"}", "g"), user[name]);
}
output += tmplCopy;
}
document.getElementById("photos").innerHTML = "<ul>"+output+"</ul><div style=\"clear:both;\"></div>";
})
.error(function(err) {
document.getElementById("photos").innerHTML = "Error getting data: "+err.message;
})
}
function getSearch() {
var output = "";
IN.API.PeopleSearch()
.params({
"current-company": "false",
"company-name": "yahoo",
"sort": "distance"
})
.fields("firstName", "lastName")
.result(function(res) {
var values = res.people.values;
for (var i = 0, len = values.length; i < len; i++) {
var user = values[i];
output += "<li>"+user.firstName+" "+user.lastName+"</li>";
}
document.getElementById("search").innerHTML = "<ul>"+output+"</ul>";
})
.error(function(err) {
document.getElementById("search").innerHTML = "Error getting data: "+err.message;
});
}
</script>
</head>
<body>
<script type="IN/Login" data-onAuth="getProfile, getConnections, getSearch">Logged in as <?js= firstName ?> <?js= lastName ?></script>
<hr/>
This is the profile for the user at URL "http://www.linkedin.com/in/jakobheuser" (based on his public profile URL). It becomes available on "Sign in"
<div id="profile"></div>
<hr/>
These are some of your connection's photos:
<div id="photos">Log In to see this data.</div>
<hr/>
Lastly, here's a search of people in your network who formerly worked at Yahoo:
<div id="search">Log In to see this data.</div>
</body>
</html>
@jakobo
Copy link
Author

jakobo commented Oct 14, 2010

@aviheidir
Copy link

line 17 of 02-profile.html, tmpl is missing closing paragraph tag.

@jakobo
Copy link
Author

jakobo commented Oct 15, 2010

Thanks. I updated that example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment