Bob*_*ano 5 javascript linkedin linkedin-api
我正在尝试将 LinkedIn api 与 JavaScript 一起使用(我是新手......)。这是我的简单代码:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="https://platform.linkedin.com/in.js">
api_key: XXXXXXXXXXXXXXXXX
authorize: true
onLoad: onLinkedInLoad
</script>
<script type="text/javascript">
// Setup an event listener to make an API call once auth is complete
function onLinkedInLoad() {
IN.Event.on(IN, "auth", getProfileData);
}
// Handle the successful return from the API call
function onSuccess(data) {
console.log("onSuccess() " + data);
console.log(data);
}
// Handle an error response from the API call
function onError(error) {
console.log("onError() " + JSON.stringify(error));
console.log(error);
}
// Use the API call wrapper to request the member's basic profile data
function getProfileData() {
console.log(IN.User.isAuthorized());
IN.API.Raw("/people/~").result(onSuccess).error(onError);
}
</script>
<script type="in/Login">
Welcome, <?js= firstName ?> <?js= lastName ?>.
</script>
</head>
<body>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我几乎照原样从文档中获取了它。我看到了打印,但我没有看到配置文件。我做错了什么?我已经将有效 SDK 域写为http://localhost:63342/因为这是 WebStorm 使用的。
PS 我还收到“未解析的变量或类型...”警告\错误,用于 IN、API、Even 和 Raw。
更新:我在浏览器控制台中看到:
message:"Could not find person based on: ~"
requestId:"4VCQPKNS5G"
status:404
timestamp:1477219009923
Run Code Online (Sandbox Code Playgroud)
在我看来,身份验证部分进展顺利,但在那之后它在其他地方失败了......
更新 2:我对代码进行了一些更改,主要是使用 console.log 而不是 document.write 并为 IN.User.isAuthorized() 添加了额外的日志。
| 归档时间: |
|
| 查看次数: |
1471 次 |
| 最近记录: |