我试图通过Javascript API检索linkedin用户的完整 Profiles (尤其是工作经历和教育资格) . 我设法将以下代码从谷歌和堆栈溢出拼凑起来:
<html>
<head>
<title>Test</title>
<script type="text/javascript" src="http://platform.linkedin.com/in.js">
api_key: blahblahblah
onLoad: onLinkedInLoad
authorize: true
</script>
<script type="text/javascript">
function onLinkedInLoad() {
IN.Event.on(IN, "auth", onLinkedInAuth);
}
function onLinkedInAuth() {
IN.API.Profile("me").result(displayProfiles);
// IN.API.Profile("me").fields(["industry", "network", "date-of-birth", "educations:(id,school-name)"]).result(displayProfiles);
}
function displayProfiles(profiles) {
member = profiles.values[0];
document.getElementById("profiles").innerHTML =
"<p id=\"" + member.id + "\">Hello " + member.firstName + " " + member.lastName + "</p>";
for(education in profiles.educations) {
var id = education.id;
var name = education.schoolName;
console.log(name);
}
}
</script>
</head>
<body>
<script type="IN/Login"></script>
<div id="profiles"></div>
</body>
</html>
这设法在授予访问权限后检索登录用户的姓名和姓氏 . 但是它完全无法检索任何其他内容 . 我使用公司登录来获取linkedin,我可以通过其余的api访问所有用户的信息,因此这不是访问问题;我只是不知道(并且找不到任何示例)如何使用Javascript API . 如何指定要检索的信息以及如何在返回的JSON对象中标识该信息?
1 回答
通过使用你已经注释掉的电话的变体来检查我的工作结果:检查你可以使用的fields,你在那里有"network"但是没有列出 . 也许它是旧版API的一部分?
然后你可以使用这样的返回数据: