[英]LinkedIn API - display company name of connections
使用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;
}
}
显示公司字段时正确的语法是什么?
function onLinkedInLoad() {
IN.Event.on(IN, "auth", onLinkedInAuth);
IN.API.Connections("me")
.fields("firstName", "lastName", "industry", "company-name")
.result(displayConnections)
.error(displayConnectionsErrors);
}
我通过这样做有一个可行的例子:
IN.API.Connections("me")
.fields("firstName","lastName","pictureUrl","positions")
.result(displayConnections)
.error(displayProfilesErrors);
}
然后按如下方式访问positions对象
var people = connections.values;
for(var person in people)
{
var positions = people[person].positions;
console.log("Works at " + positions.values[0].company.name);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.