I am trying to take some action as soon as the user approves a new extended permission, using a custom module.

In my case it relates to user data (populating the user's email address from facebook as soon as they grant us access)... so I decided to add a callback function to the permission dialog that fowards to the user edit page. I then tied a client_api->users_getInfo('email') call to a hook_user using op=load in my module. It would have been helpful to have a hook_fb op=FB_APP_EVENT_POST_PERMISSION to tie into instead - that way I wouldn't have to hack the fb_permission module. Here's my hack:

        if (count($perms)) {
          // http://wiki.developers.facebook.com/index.php/JS_API_M_FB.Connect.ShowPermissionDialog
	  global $user;
          $js = "FB.Connect.showPermissionDialog('" . implode(',', $perms) . "', function(perms) { document.location = 'user/".$user->uid."/edit'; });";

          fb_connect_init_js($js); // Add javascript to the next page.
        }

Thoughts?

Comments

Dave Cohen’s picture

My first thought is that if you patch fb_permission.module to do this, I'd by psyched! fb_permission.module is relatively new and has room to grow. Something like this would make sense.

I'm not sure exactly how to determine whether the permission was granted, but I believe that is something the facebook api allows you to learn, either via javascript or some other way.

I think the email is something we can save automatically, too. Ideally a module would simply add it to the account, rather than sending them to user/edit.

aronmalkine’s picture

Do you know if storing email is against the FB terms of (ab)use?

Dave Cohen’s picture

I am no lawyer, but if I were building an app right now and a user granted the extended permission, I'd save it to the users.mail field.

http://wiki.developers.facebook.com/index.php/Communicating_with_Users_v...

ccshannon’s picture

Oops. It looks like it IS there ... in function fb_permission_fb()

I'm going to attempt a similar hook_user addition, because I'm using the Notifications module and it uses the user.mail field for email addresses.