Facebook的动作脚本3 API登录/注销的问题脚本、动作、问题、Facebook

2023-09-08 12:51:00 作者:姑且独酌饮

我在做移动AIR应用程序为Android使用Flash Builder 4.5,AIR 2.6的 Facebook的动作脚本3 API的最新版本。

我有一个登录/注销的问题。我可以登录只有一次 - 那么我的数据高速缓存以某种方式和Facebook自动登录我当我打电话注销我收到的反应真的,但我真的不从系统中注销。标准的登录对话框中没有出现我。我已经阅读了大量的官方网站上的计算器的文章和开放性的问题,但他们都不是有益的。我该如何解决这个问题?这里是code我用:

 包
{
    进口flash.display.DisplayObject;
    进口flash.display.Sprite;
    进口的flash.display.Stage;
    进口flash.display.StageAlign;
    进口flash.display.StageScaleMode;
    进口对象类型:flash.events.Event;
    进口flash.events.IOErrorEvent在;
    进口的flash.external.ExternalInterface;
    进口flash.net.URLLoader;
    进口flash.net.URLRequest;
    进口flash.system.Capabilities;
    进口类flash.system.Security;
    进口flash.display.Loader;
    进口com.facebook.graph.FacebookMobile;

        公共类TestProj扩展Sprite
        {
            公共职能TestProj()
            {
                超();

                //注册中添加到舞台
                this.addEventListener(Event.ADDED_TO_STAGE,onAddedToStage);

                //支持在autoOrients
                stage.align = StageAlign.TOP_LEFT;
                在Stage.scaleMode = StageScaleMode.NO_SCALE时;
            }

            私有函数onAddedToStage(事件:事件):无效
            {
                this.removeEventListener(Event.ADDED_TO_STAGE,onAddedToStage);

                FacebookMobile.init(195053007196177,initCallback);
            }

            私有函数initCallback(成功:对象,失败:对象):无效
            {
                VAR appPermissions:阵列=新阵列(read_stream,offline_access,publish_stream,read_friendlists);
                FacebookMobile.login(loginCallback,this.stage,appPermissions);
                //FacebookMobile.logout(logoutCallback);
            }

            私有函数loginCallback(成功:对象,失败:对象):无效
            {
//在这里,我总是收到的成功与我的用户名
//和登录对话框不会出现在我面前这个
                如果(成功)
                {
                    跟踪(Login好);
                }
                其他
                    跟踪(登录失败);
            }

            私有函数logoutCallback(成功:对象):无效
            {
//这里我reseive真永远!
                跟踪(成功);
            }

        }
    }
 

解决方案

你只是路过logoutCallback的第一个参数到您的logout方法。如果您在为您的应用程序指定的网站URL的第二个参数添加,就应该清除出该窗口的HTML的cookie。此外,设置FacebookMobile.manageSession = FALSE;

  FacebookMobile.logout(logoutCallback,HTTP:// your_app_origin_url);
 

目前,涉及台式机和移动没有访问或清除访问令牌是同样的方式潜在的,相关的bug。对于这一点,有一个黑客工具,用来描述暴露访问令牌在FacebookMobile,然后手动调用注销的方法与访问令牌。该问题进行说明,其中包括一个所谓的reallyLogout的方法。 如果我上面写的不工作,实施reallyLogout

建立RESTful API测试程序的基础

当你退出登录,您的应用程序将清除当地的会议,但不记录你从系统中。这显然是在the文档注销。想想看,如果你在你的智能手机,Web浏览器,现在这个手机桌面应用程序登录到Facebook和你突然注销...它不应该您注销无处不在,只是内的浏览器会话。所以传递的第二个参数。

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

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

        }
    }

解决方案

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");

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

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.