Unable to logout from linkedin using javascript api

岁酱吖の 提交于 2019-11-29 17:01:16
Paul Mennega

It looks like you are trying to call IN.User.logout() before the LinkedIn JavaScript platform has completely loaded. You should run the code only once you are sure the library is loaded, via either the onLoad value in the platform bootstrap section:

<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>

Alternatively, use one of the 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>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!