使用LinkedIn Javascript API我无法弄清楚如何显示公司连接名称。
大部分内容来自LinkedIN API简介
// 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);
}
这是问题所在:
// 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;
}
}
显示公司字段时的正确语法是什么?
答案 0 :(得分:0)
function onLinkedInLoad() {
IN.Event.on(IN, "auth", onLinkedInAuth);
IN.API.Connections("me")
.fields("firstName", "lastName", "industry", "company-name")
.result(displayConnections)
.error(displayConnectionsErrors);
}
答案 1 :(得分:0)
我有一个工作的例子:
IN.API.Connections("me")
.fields("firstName","lastName","pictureUrl","positions")
.result(displayConnections)
.error(displayProfilesErrors);
}
然后按如下方式访问位置对象
var people = connections.values;
for(var person in people)
{
var positions = people[person].positions;
console.log("Works at " + positions.values[0].company.name);
}