Instagram Api User Logout

淺唱寂寞╮ 提交于 2019-11-28 08:36:35

You could use an iframe in your own "logout" page. Something like:

<iframe src="https://instagram.com/accounts/logout/" width="0" height="0" />

You probably want to redirect to the main page after the log out is performed.

Hope that helped.

If you are using PHP/HTML I would put a hidden IMG element with the SRC attribute pointed at the Instagram logout URL.

If Bhavik S's answer didn't work for you, like me, because of XFrame Options being set to SAMEORIGIN, try putting the logout in an image's src:

<img src="http://instagram.com/accounts/logout/" width="0" height="0" />

You can use an ajax call, which gives you another benefit that in case of an HTTP error due to any reason you'll get exception and you can find either it was logged out or you got any http error. Also in case of success you can run some code to show or hide any component on your page without any page refresh.

        $.ajax({
            url: "https://instagram.com/accounts/logout/",
            success: function (data) {
            },
            error: function (e) {
                alert('Error::' + e.responseText);
                //in case of any error you can put some code here.
            }
        });
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!