FB.Connect.showPermissionDialog

Description

Method for prompting the user to grant the application one or more extended permissions.

Examples

Request permission to get a permanent session for this user.

 FB.Connect.showPermissionDialog("offline_access");

Request offline_access permission, and save it if it is granted successfully.

 FB.Connect.showPermissionDialog("offline_access", function(perms) {
   if (!perms) {
     continue_without_permission();
   } else {
     save_session();
   }
 });

Permissions dialog

Request a few permissions at the same time.

 FB.Connect.showPermissionDialog(
    "publish_stream,offline_access,photo_upload",
    permissionHandler);

Permissions prompt for multiple permissions

Request stream_publish permission for any of the user's pages.

 FB.Connect.showPermissionDialog(
    "publish_stream",   // permission name(s)
    permissionHandler,  // response callback
    true);              // enable profile selector (only for "publish_stream")

Permissions dialog for anything

Finally, request stream_publish for a specific page.

 FB.Connect.showPermissionDialog(
     "publish_stream",
     permissionHandler,
     true,
     [6557022494]); // only allow user to choose "Big Bank USA"

Permissions dialog for specific page

簽名

showPermissionDialog(String permissions,  Function callback,  Boolean enableProfileSelector,  Array profileSelectorIds)

Parameters

permissionsString

The extended permission(s) to request. Pass the permissions as a string of comma-separated values.

callbackFunction

A callback function to be called when the user responds to the permissions dialog. Callback takes one string parameter. On success, the callback is passed a string with a comma-separated list of the permissions the user has granted. If the user cancels the permissions dialog, then the callback is passed an empty string.

enableProfileSelectorBoolean

Applies only if requesting the "publish_stream" permission for a Page admin. If true, then a dropdown list will appear in the permission dialog for Page admins. This allows the user to select for which Page(s) the permission should be granted. If the user isn't an admin of any Pages, then the dropdown will not appear. After the user grants the permission, you can use the page_admin and permissions tables to query which Pages that the user administers have the permission. (Default value is false.)

profileSelectorIdsArray

An array of Page and/or user IDs used to filter the IDs shown in the dropdown described in the showProfileSelector parameter. Use it when you wish to request the publish_stream permission for a specific Page or set of Pages. (Default value is null.)