I wrote a simple application for facebook and it seems that i fail to login. I created a test application on facebook and i test my application by going to apps.facebook.com/
i have the following function that is being executed after ApplicationComplete event of my main application.
private function initFacebook():void {
fbApiKey = "API_KEY";
fbSecret = "SECRET";
fbLoaderInfo = stage.loaderInfo;
fbSession = new FacebookSessionUtil( fbApiKey, fbSecret, fbLoaderInfo);
fbSession.addEventListener( FacebookEvent.WAITING_FOR_LOGIN, fbWaitingForLoginHandler, false, 0, true );
fbSession.addEventListener( FacebookEvent.CONNECT, fbConnectHandler, false, 0, true );
fbSession.login();
}
private function fbWaitingForLoginHandler( e:FacebookEvent ):void
{
fbSession.validateLogin();
}
private function fbConnectHandler( e:FacebookEvent ):void
{
Alert.show(fbSession.facebook.is_connected ? ' connected' : 'not connected');
}
I get an alert that I'm not connected and i cannot fetch any information. I entered the proper api key and secret.
If it fails to do something, how can i debug and see exactly where it failed ?
thansk
the following does work: private var fbook:Facebook; private var session:FacebookSessionUtil; private var fbUser:FacebookUser;
private function initFacebook():void {
session=new FacebookSessionUtil(API_KEY,SECRET,loaderInfo);
session.addEventListener(FacebookEvent.CONNECT,onConnect);
fbook=session.facebook;
session.login();
}
private function onConnect(e:FacebookEvent):void{
var call:FacebookCall=fbook.post(new GetInfo([fbook.uid],[GetInfoFieldValues.ALL_VALUES]));
call.addEventListener(FacebookEvent.COMPLETE,onGetInfo);
}
private function onGetInfo(e:FacebookEvent):void{
this.fbUser=(e.data as GetInfoData).userCollection.getItemAt(0) as FacebookUser;
<!-- fetching facebook user information from this.fbUser -->
}
and i created a button that executes the following function: (only after I'm logged-in into facebook)
private function onConfirmLogin():void{
session.validateLogin();
}