我有一段代码可以将用户从linkedin中注销并且无法正常工作:(
任何帮助将不胜感激。
退出代码
<html>
<head>
<script type="text/javascript" src="http://platform.linkedin.com/in.js">
api_key: mykey
authorize: true
</script>
<script type="text/javascript">
try {
IN.User.logout();
} catch (err) {
console.log(err);
}
setTimeout("goToHome()", 10000);
function goToHome() {
location.href="index.php";
}
</script>
</head>
</html>
控制台日志
TypeError
arguments: Array[2]
get message: function () { [native code] }
get stack: function () { [native code] }
set message: function () { [native code] }
set stack: function () { [native code] }
type: "non_object_property_call"
__proto__: Error
祝你好运, 爬完
答案 0 :(得分:3)
看起来你试图在LinkedIn JavaScript平台完全加载之前调用IN.User.logout()。只有在确定加载库后,才能通过平台引导程序部分中的onLoad值运行代码:
<script type="text/javascript" src="http://platform.linkedin.com/in.js">
api_key: mykey
authorize: true
onLoad: onLoad
</script>
<script type="text/javascript">
function onLoad() {
try {
IN.User.logout();
} catch (err) {
console.log(err);
}
setTimeout("goToHome()", 10000);
}
function goToHome() {
location.href="index.php";
}
</script>
或者,使用event callbacks之一:
<script type="text/javascript" src="http://platform.linkedin.com/in.js">
api_key: mykey
authorize: true
</script>
<script type="text/javascript">
IN.Event.onOnce(IN, 'systemReady', function() {
try {
IN.User.logout();
} catch (err) {
console.log(err);
}
setTimeout("goToHome()", 10000);
});
function goToHome() {
location.href="index.php";
}
</script>