Skip to content

Instantly share code, notes, and snippets.

@SergioLarios
Created November 3, 2016 16:58
Show Gist options
  • Save SergioLarios/32b4e4be906345dee1e9524511089a7d to your computer and use it in GitHub Desktop.
Save SergioLarios/32b4e4be906345dee1e9524511089a7d to your computer and use it in GitHub Desktop.
<script type="text/javascript" src="https://platform.linkedin.com/in.js">
api_key: 77n96cw5jr1gb9
onLoad: onLinkedInLoad,onLinkedInAuth
authorize: false
</script>
<div id="displayUpdates"></div>
<script type="text/javascript">
function onLinkedInLoad() {
IN.Event.on(IN, "auth", onLinkedInAuth);
console.log("On auth");
}
function onLinkedInAuth() {
var cpnyID = 12190; //LinkedIn's testDevCo
IN.API.Raw("/companies/" + cpnyID + "/updates?event-type=status-update&start=0&count=10&format=json")
.result(displayCompanyUpdates);
console.log("After auth");
}
function displayCompanyUpdates(result) {
var div = document.getElementById("displayUpdates");
var el = "<ul>";
var resValues = result.values;
for (var i in resValues) {
var share = resValues[i].updateContent.companyStatusUpdate.share;
var isContent = share.content;
var isTitled = isContent,
isLinked = isContent,
isDescription = isContent,
isThumbnail = isContent;
if (isTitled) {
var title = isContent.title;
} else {
var title = "News headline";
}
if (isLinked) {
var link = isContent.shortenedUrl;
} else {
var link = "#";
}
if (isDescription) {
var description = isContent.description;
} else {
var description = "No description";
}
if (isThumbnail) {
var thumbnailUrl = isContent.thumbnailUrl;
} else {
var thumbnailUrl = "http://placehold.it/60x60";
}
if (share) {
var content = "<a target='_blank' href=" + link + ">" + title + "</a><br>" + description;
el += "<li><img src='" + thumbnailUrl + "' alt=''>" + content + "</li>";
}
console.log(share);
}
el += "</ul>";
div.innerHTML = el;
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment