AS3 - Facebook.init返回两个空的成功和失败的对象 [英] AS3 - Facebook.init returning both null for success and fail objects

查看:184
本文介绍了AS3 - Facebook.init返回两个空的成功和失败的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经做了两个测试

  1. 当我登录,我得到的成功作为内部initHandler有效的对象
  2. 当我没有登录到Facebook的,我得到的成功和失败的内外initHandler为空,所以我在我的其他情况下Facebook.login。然后会提示登录的用户,但在填写用户名和密码后,我loginHandler不会被调用,如何将我的应用程序知道,他登录的,所以我也可以继续玩游戏,它是如何工作了吗?请指教。

     私有函数连接(ID:字符串):无效{
        在Security.loadPolicyFile(https://fbcdn-profile-a.akamaihd.net/crossdomain.xml);
        Facebook.init(ID,initHandler);
    }
    
    私有函数initHandler(成功:对象,失败:对象):无效{//成功,失败都是空
        如果(成功){
    
        } 其他 {
            Facebook.login(loginHandler,{适用范围:电子邮件,user_location});
        }
    }
    
    私有函数loginHandler(成功:对象,失败:对象):无效{
        如果(成功){
    
        } 其他 {
            //没有给出权限
    
        }
    }
     

解决方案

参照点在我的问题,我的loginHandler当时不叫#2,我发现了另外一个帖子,说要延迟登录电话,以下是完整序列的code运行。

 公共职能授权():无效{
        VAR回应:FacebookAuthResponse = Facebook.getAuthResponse();
        如果(响应和放大器;&安培; response.uid){
            this.success(响应);
        } 其他 {
            this.init();
        }
    }

    保护功能的init():无效{
        在Security.loadPolicyFile(https://fbcdn-profile-a.akamaihd.net/crossdomain.xml);
        Facebook.init(this.appID,this.initHandler);
    }

    保护功能initHandler(回应:FacebookAuthResponse,失败:对象):无效{
        如果(响应和放大器;&安培; response.uid){
            this.success(响应);
        } 其他 {
            的setTimeout(this.login,200);
        }
    }

    保护功能登录():无效{
        Facebook.login(loginHandler,this.permissions);
    }

    保护功能loginHandler(回应:FacebookAuthResponse,失败:对象):无效{
        如果(响应和放大器;&安培; response.uid){
            this.success(响应);
        } 其他 {
            //未授权
        }
    }

    保护功能成功(回应:FacebookAuthResponse):无效{
        //授权
    }
 

I've done two tests

  1. When I'm logged in, I get success as a valid object inside initHandler
  2. When I'm not logged into the Facebook, I get success and fail both as null inside initHandler, so I've Facebook.login in my else case. which then prompts the user to login, but after filling in username and password, my loginHandler doesn't get called, how would my application know that he's logged in so I can go ahead and play the game, how it works out there? Please advise.

        private function connect(id:String):void { 
        Security.loadPolicyFile("https://fbcdn-profile-a.akamaihd.net/crossdomain.xml");
        Facebook.init(id, initHandler);
    }
    
    private function initHandler(success:Object, fail:Object):void { //success, fail are null
        if(success){
    
        } else {
            Facebook.login(loginHandler,{scope:"email, user_location"});
        }
    }
    
    private function loginHandler(success:Object, fail:Object):void {
        if(success) {
    
        } else {
            //permissions not given
    
        }
    }
    

解决方案

Referring to point # 2 in my question, where my loginHandler wasn't called, I found another post that says to delay the login call, Here's the complete sequence of the code to run.

    public function authorize():void {
        var response:FacebookAuthResponse = Facebook.getAuthResponse();
        if(response && response.uid) {
            this.success(response);
        } else {
            this.init();
        }
    }

    protected function init():void { 
        Security.loadPolicyFile("https://fbcdn-profile-a.akamaihd.net/crossdomain.xml");
        Facebook.init(this.appID, this.initHandler);
    }

    protected function initHandler(response:FacebookAuthResponse, fail:Object):void {
        if(response && response.uid){ 
            this.success(response);
        } else { 
            setTimeout(this.login, 200);
        }
    }

    protected function login():void {
        Facebook.login(loginHandler, this.permissions);
    }

    protected function loginHandler(response:FacebookAuthResponse, fail:Object):void {
        if(response && response.uid) {
            this.success(response);
        } else {
            //not authorized
        }
    }

    protected function success(response:FacebookAuthResponse):void {
        //authorized
    }

这篇关于AS3 - Facebook.init返回两个空的成功和失败的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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