如何为 Facebook 图形 API 实现注销功能

发布于 2024-10-13 03:22:09 字数 208 浏览 6 评论 0原文

我在我的 iPhone 应用程序中实现了 Facebook Graph API,并成功地将其发布在墙上。但每次我结束我的应用程序并返回时,它都会存储我的凭据(在 Safari 中我猜是一个 cookie)。它需要我之前的凭据来征求我的许可。但此时我希望我的 Facebook API 应该提示输入新的用户名和密码登录以请求权限。简而言之,当我在应用程序中选择一个按钮时,我想注销我的 Facebook。

I implemented Facebook Graph API in my iPhone App and I successfully post it in a wall. But each time I end my application and come back it stores my credentials (in Safari I guess as a cookie). It asks my permission with my previous credentials. But at this point I want my Facebook API should prompt for a new username and password login for requesting permission. In simple I want to logout of my Facebook when i select a button in my App.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

沉鱼一梦 2024-10-20 03:22:10
fbGraph.accessToken = nil;
NSHTTPCookie *cookie;
NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (cookie in [storage cookies])
{
    NSString *domainName = [cookie domain];
    NSRange domainRange = [domainName rangeOfString:@"facebook"];
    if(domainRange.length > 0)
    {
        [storage deleteCookie:cookie];
    }
}
fbGraph.accessToken = nil;
NSHTTPCookie *cookie;
NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (cookie in [storage cookies])
{
    NSString *domainName = [cookie domain];
    NSRange domainRange = [domainName rangeOfString:@"facebook"];
    if(domainRange.length > 0)
    {
        [storage deleteCookie:cookie];
    }
}
來不及說愛妳 2024-10-20 03:22:10

您最初是如何登录 Facebook 的?如果您使用 facebook iOS SDK,您只需调用 [facebook logout:self]; 即可。否则,如果您自己实现 Graph API,则只需清除您的 cookie 并删除您的访问令牌。

How did you log in to facebook in the first place? If you are using facebook iOS SDK, you just basically have to call [facebook logout:self];. Otherwise if you're implementing Graph API yourself you just need to clear out your cookies and delete your access token.

酒几许 2024-10-20 03:22:10

当您在该方法的最后一行调用 facebook 按钮时,您将编写此方法 [facebook logout]

when you are call the facebook button at that method last line u wil write this method [facebook logout]

羁〃客ぐ 2024-10-20 03:22:10
NSHTTPCookieStorage* cookies = [NSHTTPCookieStorage sharedHTTPCookieStorage];
        for (NSHTTPCookie* cookie in [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies])
        {
            [cookies deleteCookie:cookie];
        }

这些代码足以实现注销功能。

它在我的应用程序上完美运行。

NSHTTPCookieStorage* cookies = [NSHTTPCookieStorage sharedHTTPCookieStorage];
        for (NSHTTPCookie* cookie in [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies])
        {
            [cookies deleteCookie:cookie];
        }

These codes are enough to implement logout functionality.

Its working perfectly on my app.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文