Logout from LinkedIn API
Make sure that you have include
<script type="text/javascript" src="http://platform.linkedin.com/in.js"></script>
on your home page, i.e. where you are logging out.
Seems your onclick
is not being called, try doing:
function closeSession(){ IN.User.logout(); return true;}<a href="logout.php" class="myButton" onclick="return closeSession();" id="logout-link">Logout In LinkedIn</a>
OR
<a href="#" class="myButton" onclick="closeSession()" id="logout-link"> Logout In LinkedIn</a>
And js
function closeSession() { if ( typeof IN === 'object' && typeof IN.User === 'object' && IN.User.isAuthorized() ) { //user logged in linkedin //call linkedin logout with websites logout function as callback alert("I m inside linkedin object check.."); //do you see this IN.User.logout(logout); } else { logout(); }}function logout() { window.location.href = "URL_TO_YOUR_LOGOUT.PHP";}
I think you are redirected before your javascript gets executed, so try this way ?JavaScript Code :
function closeSession(){ IN.User.logout(); location.href="logout.php";}
HTML Code :
<span style="cursor:pointer" onclick="closeSession()">Logout In LinkedIn</span>