Closed GoogleCodeExporter closed 8 years ago
if user is logged in and has already allowed permissions Facebook.init runs
fine.
if permissions were never allowed Facebook.init doesn't run.
Original comment by joaobel...@gmail.com
on 25 Apr 2011 at 5:18
I'm using Graph API 1.6.
if user is logged in and has already allowed permissions Facebook.init runs
fine.
if permissions were never allowed Facebook.init doesn’t run.
I think that my index.php is ok, else Facebook.init would never run and it does
when permissions were previously allowed.
//---------------------------------------------------------------------
// actionscript.as
//---------------------------------------------------------------------
Facebook.init("APP_ID", onInit);
private function onInit(result:Object, fail:Object):void
{
if (result)
{
trace("SUCCESS");
}
else
{
trace("FAIL");
}
}
(this actually works when the user has a session opened and had permitted the
app)
//---------------------------------------------------------------------
// index.php
//---------------------------------------------------------------------
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"</script>
<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>
</head>
<body>
<div id="fb-root"></div>
<div id="flashContent"></div>
<script type="text/javascript">
swfobject.embedSWF("FlashWebExample.swf?<? echo(time()) ?>", "flashContent", "650", "700", "9.0", null, null, null, {name:"flashContent"});
</script>
</body>
</html>
What's wrong?
Original comment by joaobel...@gmail.com
on 25 Apr 2011 at 5:59
Are you able to get a response when using just the Facebook Javascript SDK?
http://developers.facebook.com/docs/reference/javascript/FB.init/
http://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus/
<script>
FB.init({appId: 'YOUR_APP_ID'} );
FB.getLoginStatus(
function( response ) {
if( response.session ) {
alert('status session:' + response.session);
} else {
alert('status no session');
}
}
);
</script>
The API makes a call to FB.getLoginStatus() during init(), which should cause
it to run the init callback.
Original comment by edwar...@gmail.com
on 25 Apr 2011 at 10:48
No I don't get a response.
I'm attaching a php.
Original comment by joaobel...@gmail.com
on 26 Apr 2011 at 3:02
I've bee searching testing and trying to learn about this subject...
I figured that Facebook.init is running and either returning NULL or a USERID
depending on login status and permissions.
So I have a new question:
When Facebook.init returns null should I run Facebook.login or should I present
the user with an option to login? What is the best practice?
Do you have any documentation about best practices on this subject?
Original comment by joaobel...@gmail.com
on 27 Apr 2011 at 9:14
When Facebook.init() returns null, it just simply means you're not currently
logged in. Although you can call Facebook.login() at this point, you may run
into an issue with your browser blocking the login popup. This is because the
popup was not initiated through an user interaction, so its usually better to
present the user with an option to login.
Original comment by edwar...@gmail.com
on 6 May 2011 at 4:07
Here is my dirty hack of a solution which worked perfectly:
public class FacebookConnect
{
public static var isConnected:Boolean = false;
public static var connecting:Boolean = false;
private var initDone:Function;
private var perms:Object;
private var tm:uint;
private var appID:String
public function FacebookConnect( _appID:String, _perms:Object, _initDone:Function )
{
perms = _perms;
initDone = _initDone;
appID = _appID;
init( );
}
private function init( ):void
{
connecting = true;
Facebook.init( appID );
if( Facebook.getSession( ) == null)
{
freshLogin( );
checkForSession( );
}else{
loginDone( );
}
}
private function checkForSession( ):void
{
var fs:* = Facebook.getSession( ).uid;
Logger.log("FacebookConnect.checkForSession.uid."+fs);
if( null != fs)
{
loginDone( );
return;
}else{
setTimeout( checkForSession, 1000);
}
}
private function loginDone( ):void
{
Facebook.init(
appID,
initComplete,
{
channelURL : 'http://mjdev.rtedge.ca/mpbj/channel.html'
}
);
}
private function freshLogin( ):void
{
Logger.log("FacebookConnect.freshLogin");
login( );
}
private function login( ):void
{
perms['channelURL'] = 'http://mjdev.rtedge.ca/mpbj/channel.html';
Facebook.login
(
null,
perms
);
}
private function initComplete(s:Object,f:Object):void
{
Logger.log("FacebookConnect._initDoneInternal."+s+":"+f);
FacebookConnect.isConnected = s != null;
if( s != null ) initDone( s , f );
Logger.log( "FacebookConnect."+FacebookConnect.isConnected+":"+JSON.encode(s)+":"+JSON.encode(f) );
}
}
Original comment by marcin.a...@gmail.com
on 28 Jun 2011 at 7:47
For a complete workaround to the Facebook.init() problem see this post:
http://blog.flexwiz.net/facebook-as3-api-blues/
Original comment by amos...@gmail.com
on 5 Jul 2011 at 10:26
Original comment by edwar...@gmail.com
on 13 Oct 2011 at 7:56
Original issue reported on code.google.com by
joaobel...@gmail.com
on 23 Apr 2011 at 6:22