Using the LinkedIn Javascript API I can't work out how to display the Company Name of connections.
Most of this is stock from the LinkedIN API intro
// This seems to be correctly getting the company data
function onLinkedInLoad() {
IN.Event.on(IN, "auth", onLinkedInAuth);
IN.API.Connections("me")
.fields("firstName", "lastName", "industry", "positions:(company)")
.result(displayConnections)
.error(displayConnectionsErrors);
}
Here's the problem though:
// The Last line is wrong where I try to call the company object
// (members[member].company)
function displayConnections(connections) {
var connectionsDiv = document.getElementById("connections");
var members = connections.values; // The list of members you are connected to
for (var member in members) {
connectionsDiv.innerHTML += "<p>" + members[member].firstName + " " + members[member].lastName
+ " works in the " + members[member].industry + " industry at" + members[member].company;
}
}
What is the correct syntax when displaying the company fields?
function onLinkedInLoad() {
IN.Event.on(IN, "auth", onLinkedInAuth);
IN.API.Connections("me")
.fields("firstName", "lastName", "industry", "company-name")
.result(displayConnections)
.error(displayConnectionsErrors);
}
I have a working example of that by doing:
IN.API.Connections("me")
.fields("firstName","lastName","pictureUrl","positions")
.result(displayConnections)
.error(displayProfilesErrors);
}
and then accessing the positions object as follow
var people = connections.values;
for(var person in people)
{
var positions = people[person].positions;
console.log("Works at " + positions.values[0].company.name);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.