Instagram Api User Logout

不羁岁月 提交于 2019-11-27 02:18:27

问题


How do I perform a logout from my application only (not from the instagram account - but yes from my app) ?

I saw some people saying "refer the user to the instagram logout page" but it's not what I really need.


回答1:


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.




回答2:


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



回答3:


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




回答4:


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.
            }
        });


来源:https://stackoverflow.com/questions/10991753/instagram-api-user-logout

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