GRiMe2D / facebook-actionscript-api

Automatically exported from code.google.com/p/facebook-actionscript-api
0 stars 0 forks source link

Facebook.login does not open dialog (and Facebook.init returns null,null) #371

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
For the Facebook.init issue:
1. I have my HTML file configured properly - I imported the Facebook Javascript 
file, added the fb-root div above the others, I embedded my swfobject 
appropriately, I even imported FBML for the hell of it.
2. My swf and html are living on the domain I listed with Facebook, in the 
directory I noted as the web page.
3. Call Facebook.init - it returns null, null. No error for fail. Is this 
because the Javascript Bridge already initializes the app, and Facebook.init is 
only to detect login? If so, this is understandable - However, the next problem 
is more pertinent:

For the Facebook.login issue:
1. I have a null Facebook.init return, so I have tried this in multiple manners 
- either directly calling Facebook.login when the returnHandler is called from 
Facebook.init, or providing a user with a button that will call a handler that 
executes Facebook.login.
2. Click the button - Facebook.login(onLogin,opts) runs, but onLogin is never 
called.

What is the expected output? What do you see instead?
I expect to see a popup to log in to Facebook or approve the app! 

What version of the product are you using? On what operating system?
Using Flash 10, AS3 API 1.8.1. I am running FlashPlayer 11, but earlier today I 
tested an older version of the AS3 API from early this year on the same 
FlashPlayer, and I was able to get the popup and log in without a problem. 

Please provide any additional information below.
This fails on every single browser. Nothing I do can make the login dialog pop 
up. Not having a button to call login instead of doing it immediately after 
init, not putting it on a different domain or on localhost or in a subdomain, 
not changing the swf's wmode (shouldn't have an effect anyway), nothing.

Original issue reported on code.google.com by ort...@gmail.com on 25 Oct 2011 at 10:18

GoogleCodeExporter commented 9 years ago
Update: Installed Flash Player 10.3 again to test it - same thing all across 
the board.

I figured I might as well show you the code so you can see what I'm doing. This 
is taken directly from a sample done previously as a tutorial to get this 
working. It has worked consistently prior to updating the library earlier today.

        protected static const APP_ID:String = "_IDHERE_";
        protected static var opts:Object = {perms:"publish_stream,user_photos,user_activities,read_mailbox"};

        public function FlashWebMain() {    
            configUI();
        }

        protected function configUI():void {
        //hide the params input by default
        paramsLabel.visible = paramsInput.visible = false;          

            //listeners for UI
            loginToggleBtn.addEventListener(MouseEvent.CLICK, handleLoginClick, false, 0, true);
            callApiBtn.addEventListener(MouseEvent.CLICK, handleCallApiClick, false, 0, true);          
            getRadio.addEventListener(MouseEvent.CLICK, handleReqTypeChange, false, 0, true);
            postRadio.addEventListener(MouseEvent.CLICK, handleReqTypeChange, false, 0, true);
            clearBtn.addEventListener(MouseEvent.CLICK, handleClearClick, false, 0, true);

            //Initialize Facebook library
            Facebook.init(APP_ID, onInit, opts);            
        }

        protected function onInit(result:Object, fail:Object):void {    
            trace("onInit:");
            if (result != null) { //already logged in because of existing session
                trace("Logged in!");
                outputTxt.text = "onInit, Logged In As "+result.uid+"\n";
                loginToggleBtn.label = "Log Out";
            } else {
                trace("Not logged in: "+fail);
                outputTxt.text = "onInit, Not Logged In\n";
            }
        }

        protected function handleLoginClick(event:MouseEvent):void {
            if (loginToggleBtn.label == "Log In") {
                trace("Trying Facebook Login!");
                Facebook.login(onLogin, opts);
            } else {
                Facebook.logout(onLogout);
            }
        }

        protected function onLogin(result:Object, fail:Object):void {
            if (result) { //successfully logged in
                outputTxt.text = "Logged In As "+result.uid+"\n";
                loginToggleBtn.label = "Log Out";
            } else {
                outputTxt.appendText("Login Failed\n");             
            }
        }

Original comment by ort...@gmail.com on 25 Oct 2011 at 10:39

GoogleCodeExporter commented 9 years ago
After hours of frantic comparisons back and forth between the examples, I 
determined my problem was the line

protected static var opts:Object = 
{perms:"publish_stream,user_photos,user_activities,read_mailbox"};

At some point the perms object was changed to scope. In my massive panic I 
never noticed the miniscule change:

private static const opts:Object        = {scope:"user_photos,user_birthday,email"};

No bug to report.

Original comment by ort...@gmail.com on 25 Oct 2011 at 11:42

GoogleCodeExporter commented 9 years ago

Original comment by edwar...@gmail.com on 26 Oct 2011 at 3:41