Facebook API SDK revoke access

前端 未结 4 1369
灰色年华
灰色年华 2020-11-30 05:50

How can I allow a user to revoke access to my application using their API service, SDK. http://developers.facebook.com/docs/sdks/

Looking at the documentation I can\

4条回答
  •  情歌与酒
    2020-11-30 06:47

    For anyone who would find this helpful, I was losing sleep and wrecking my brain for days trying to get this to work;

    FB.api('/me/permissions', 'DELETE', function(response) {
        if (response == true) {
            window.top.location = 'logout-facebook.php';
        } else {
            alert('Error revoking app');
        }
    });
    

    I finally got this to work when I observed that the "response" being returned was not a boolean but a JSON object.

    The JSON object being returned was either;

    {
        success: "true"
    }
    

    OR

    {
        success: "false"
    }
    

    Following that, the correct code was;

    FB.api('/me/permissions', 'DELETE', function(response) {
        if (response.success == true) {
            window.top.location = 'logout-facebook.php';
        } else {
            alert('Error revoking app');
        }
    });   
    

    Hope this helps someone!

提交回复
热议问题