Login FB with GraphAPI_Source_1_8_1.

552 views
Skip to first unread message

Do TranVan

unread,
Jan 7, 2014, 11:14:10 PM1/7/14
to facebook-act...@googlegroups.com
I can't connect fb with GraphAPI_Source_1_8_1.
this's is my code:
    protected static const APP_ID :String = "XXXXXXXXXX";
            protected function init(event:FlexEvent):void
            {
                // TODO Auto-generated method stub
                Facebook.addJSEventListener("auth.login", authLoginHandler);
                Facebook.init(APP_ID,callBack);
            }
            protected function authLoginHandler(result:Object):void
            {
                //if(result && result.session)
                    //loginHandler(result.session, null);
            }
            public function callBack(response:Object, fail:Object):void
            {
                //Callback of the init Function if the user is logged in and he already alowed the app fail will be null
                // and response will contain some information like the acessToken
                if(response != null)
                {
                    // we don't need to login you can get user information like Facebook.api("/me", getMeHandler); see getUserInfo function
                    Facebook.api("/me", getMeHandler);
                    connect.visible = false;
                    getUserInfo();
                }
                else
                {
                    connect.addEventListener(MouseEvent.CLICK, onClick);
                }
               
            }
           
            public function onClick(e:MouseEvent):void
            {
                Facebook.login(loginCallBack,{scope:"stream_publish, email"});//https://developers.facebook.com/docs/reference/api/permissions/
                //for more info about permission
            }
           
            public function loginCallBack(result:Object, fail:Object):void
            {
                if(result != null)
                {
                    getUserInfo();
                }
            }
           
            public function getUserInfo():void
            {
                Facebook.api("/me", getMeHandler);
            }
            public function getMeHandler(me:Object, fail:Object):void
            {
                //me.name
                //me.first_name
                //me.email etc.......
            }

Khaled Garbaya

unread,
Jun 11, 2014, 2:32:11 PM6/11/14
to facebook-act...@googlegroups.com
looks ok to me
do you have this http://connect.facebook.net/en_US/sdk.js linked in your html page ?
try to to check in the javascript console if you have any error CTRL+SHIfT+I
Reply all
Reply to author
Forward
0 new messages