Skip to content

Instantly share code, notes, and snippets.

@benjaminfisher
Created May 20, 2012 09:23
Show Gist options
  • Select an option

  • Save benjaminfisher/2757473 to your computer and use it in GitHub Desktop.

Select an option

Save benjaminfisher/2757473 to your computer and use it in GitHub Desktop.
Script to retrieve LinkedIn recommendations via Raw API
<html>
<head>
<title>Recommendations on LinkedIn</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" src="http://platform.linkedin.com/in.js">
api_key: [YOUR API KEY]
authorize: true
</script>
<script type="text/javascript">
// Once we have an authorization, fetch the user's profile via API
function onLinkedInAuth() {
IN.API.Raw('/people/~:(recommendations-received)')
.method('GET')
.result(function(result){
var received = result.recommendationsReceived.values;
$('<p>')
.html('Recommendations: ' + received.length)
.appendTo('#recommendations');
$.each(received, function(i, data){
$('<h3>')
.html(data.recommender.firstName + " " + data.recommender.lastName)
.appendTo('#recommendations');
$('<p>')
.html(data.recommendationText)
.appendTo('#recommendations');
});
})
};
</script>
</head>
<body>
<script type="in/login" data-onAuth="onLinkedInAuth">
Hello, <?js= firstName ?> <?js= lastName ?>.
</script>
<div id="recommendations"></div>
</body>
</html>
@benjaminfisher
Copy link
Author

I have not fully tested this script.
It may just show the recommendations of whoever logs in, which would be pretty worthless.

@platonicsolz
Copy link

Please if you can find me the issue in the below code? am getting invalid xml error :(
var payload = {
"company": {
"id": "1337"
}
};
IN.API.Raw("/people/~/following/companies?format=json").method("POST").body(JSON.stringify(payload)).result(onSuccess).error(onError);

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