Prompting for Extended Permissions

Problem

I need to get permission from users to send them email, get an infinite session, update their status, upload and tag photos, and create or modify Marketplace listings. Is there an easy way to do that?

Solution

Sure is! Use the fb:prompt-permission button, which was added in the mid-2008 Profile redesign:

<fb:prompt-permission perms="set_status">Can we set your status?
 </fb:prompt-permission>

The tag will display the text (or any other FBML) you put into it as a link that opens a confirmation dialog like the one shown in Figure 6-44.

Prompt permissions confirmation dialog

Figure 6-44. Prompt permissions confirmation dialog

Discussion

The following extended permission strings are available:

  • email

  • offline_access

  • status_update

  • photo_upload

  • create_listing

Facebook will show links (or other FBML) only for permissions the user hasn’t already granted you. You can optionally pass a next_fbjs parameter into the fb:prompt-permission tag to specify an FBJS function that you’d like called after permission has been granted, which gives you the option of hiding the link.

Get Facebook Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.