Facebook 操作脚本 3 API 登录/注销问题 [英] Facebook action script 3 API login/logout issue

查看:26
本文介绍了Facebook 操作脚本 3 API 登录/注销问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Flash builder 4.5、AIR 2.6、Facebook 动作脚本 3 API 最新版.

I'm making mobile AIR app for Android using Flash builder 4.5, AIR 2.6, Facebook action script 3 API the latest version.

我在登录/注销时遇到问题.我只能登录一次 - 然后我的数据以某种方式缓存,Facebook 会自动让我登录.当我调用 logout 时,我收到响应 TRUE,但我并没有真正从系统注销.我没有出现标准登录对话框.我已经在官方网站上阅读了很多关于 stackoverflow 和 open issues 的文章,但没有一篇有帮助.我该如何解决这个问题?这是我使用的代码:

I have a problem with login/logout. I can login only one time - then my data caches somehow and Facebook automatically logs me in. When I call logout I receive response TRUE, but I don't really logout from system. Standard login dialog doesn't appear for me. I have already read a lot of articles on stackoverflow and open issues on official site, but none of them were helpfull. How can I solve this? Here is the code I use:

package
{
    import flash.display.DisplayObject;
    import flash.display.Sprite;
    import flash.display.Stage;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.events.Event;
    import flash.events.IOErrorEvent;
    import flash.external.ExternalInterface;
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import flash.system.Capabilities;
    import flash.system.Security;
    import flash.display.Loader;
    import com.facebook.graph.FacebookMobile;

        public class TestProj extends Sprite
        {
            public function TestProj()
            {
                super();

                //register to add to stage
                this.addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);

                // support autoOrients
                stage.align = StageAlign.TOP_LEFT;
                stage.scaleMode = StageScaleMode.NO_SCALE;
            }

            private function onAddedToStage(event:Event):void
            {
                this.removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);

                FacebookMobile.init("195053007196177", initCallback);
            }

            private function initCallback(success:Object, fail:Object):void
            {
                var appPermissions:Array = new Array("read_stream", "offline_access", "publish_stream", "read_friendlists");
                FacebookMobile.login(loginCallback, this.stage, appPermissions);
                //FacebookMobile.logout(logoutCallback);
            }

            private function loginCallback(success:Object, fail:Object):void
            {       
//And here I always receive success with my UserID
//and login dialog don't appears to me before this  
                if (success)
                {
                    trace("login ok");
                }
                else
                    trace("login failed");
            }

            private function logoutCallback(success:Object):void
            {
//here I reseive "TRUE" always!!
                trace(success);
            }

        }
    }

推荐答案

您只是将 logoutCallback 的第一个参数传递给您的注销方法.如果您添加为您的应用程序指定的站点 url 的第二个参数,它应该清除该窗口的 html cookie.另外,设置 FacebookMobile.manageSession = false;

You're only passing the 1st argument of logoutCallback to your logout method. If you add in the 2nd argument of your site url specified for your app, it should clear it out the html cookie for that window. Also, set FacebookMobile.manageSession = false;

            FacebookMobile.logout(logoutCallback, "http://your_app_origin_url");

存在一个潜在的相关错误,涉及桌面和移动设备无法以相同的方式访问或清除访问令牌.为此,有一个 hack 描述了在 FacebookMobile 中公开访问令牌,然后使用访问令牌手动调用注销"方法.此处描述了该问题,包括一个名为reallyLogout"的方法.如果我上面写的不起作用,请实施reallyLogout".

There is a potential, related bug that involves Desktop and Mobile not accessing or clearing the access token's the same way. For that, there's a hack that describes exposing the access token in FacebookMobile, then manually calling the "logout" method with the access token. The issue is described here, including a method called "reallyLogout". If what I've written above doesn't work, implement "reallyLogout".

当您注销时,您的应用会清除本地会话,但不会将您从系统中注销.这在 注销文档. 想想看,如果你登录了 Facebook在您的智能手机、Web 浏览器和现在的移动桌面应用程序上,您突然退出...它不应该在任何地方将您退出,只是在该浏览器会话中.所以传递第二个参数.

When you log out, your app clears the local session but does not log you out of the system. This is clearly defined in the documentation for logout. Think about it, if you're logged into Facebook on your Smartphone, Web Browser, and now this Mobile Desktop App, and suddenly you log out... it shouldn't log you out EVERYWHERE, just within that browsers session. So pass that 2nd parameter.

这篇关于Facebook 操作脚本 3 API 登录/注销问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆