views:

97

answers:

1

I'm creating a Flash-based (AS3) Facebook Connect site using the Actionscript 3 API and though I've got basic FB Connect functionality in place in terms of allowing users to login correctly, I'm running into walls when trying to ask for certain extended permissions. I'm not positive, but it appears as though there are two fairly significant limitations to the AS3 API:

  1. You must prompt for extended permissions separately from the initial login call. In other words, two modal dialogs, not one, are required. This seems to be because connecting is handled with instances of FacebookSessionUtil, while extended permissions requests are handled by instances of FacebookSessionUtil.Facebook.

  2. It doesn't seem that there's a way to prompt users to allow their email address to be shared with your application. Though I've perused http://facebook-actionscript-api.googlecode.com/svn/release/current/docs/index.html quite thoroughly, it looks like the "EMAIL" permission there only prompts users to allow your app to send them email via facebook, not to share their email address directly.

Are my assumptions wrong here? Would I be better off using JS and ExternalInterface for this sort of work? I'd rather not rebuild what's in place but if these limitations are real, it appears I'll have no other choice.

Any feedback or assistance would be greatly appreciated. Thanks!

+1  A: 

1)You will have to override the onLogin function in the DesktopSession Class and add in your extended permission parameters.

2)It should work unless the change in the permissions model only allowed for proxied emails. Try querying it from the facebook user instance and see what you get.

Test it in the Developer console with the following api call in the console block

<button id="fb-login">Login &amp; Permissions</button>

<script>
document.getElementById('fb-login').onclick = function() {
  var cb = function(response) {
    Log.info('FB.login callback', response);
    if (response.session) {
      Log.info('User logged in');
      if (response.perms) {
        Log.info('User granted permissions');
      }
    } else {
      Log.info('User is logged out');
    }
  };
  FB.login(cb, { perms: 'email' });
};
</script>
phwd
Thanks, phwd. Could you be a little more specific about the nature of the onLogin override from 1)? It looks like onLogin just hits the usual Facebook login URL (http://www.facebook.com/login.php) and tacks a bunch of extra GET variables onto it. Is another variable needed in the URL?
justinbach
Yes your email extended permission parameter : `email` I tried to override the class by extending it but the DesktopSession is in everything. So I did a quick search and found out my idea has been thought of already :( . This dude [Jozef Chúťka](http://blog.yoz.sk/2010/01/facebook-extended-permissions-with-authorization-by-overriding-class-in-swc/) has a full tutorial on how to get it to work. He basically copied the class into his src using the same directory pattern as in facebook swc for that class.
phwd
Keep in mind this will only work if the user is not logged in already. FB Api (moronicly, if you ask me) fills up response.perms only if you have actually logged in. If you were loggen-in already, your callback will be called, but perms will be empty. I've struggled with this very problem last week. There's a getUserStatus method (or something along those lines) that will not return permissions either.
Juan Pablo Califano
(cont) There are only two ways around this (that I know): 1) force a logout if user is already logged in and then log them in (bad user experience, for sure). 2) Check login status and if the user is logged-in, query the current permissions using FQL (there's a permissions table) through the JS API (bad developer experience ;). I've followed the second approach, but it was a pain to get it working (considering how bad the FB docs suck; often, your best bet is trial/error and guessing). (end of rant)
Juan Pablo Califano
+1 @Juan Pablo Califano Yeah did not know that (*good and informative rant :D *) Never tried extended permissions so this was a new puzzle to me.
phwd