Facebook Extended Permissions are used to allow the user to add extended permissions, like sending upload images and status updates, to Facebook application. It is important to know correct usage of this control, in comparison with Facebook Login Button, which can also be used to set permissions. For permissions which are required for basic capabilities of your Facebook application or website, it is recommended to use Login Button, so that user can give the permissions on the first time he uses the application or the website. Permissions control is used to add extra permissions which are not crucial, but offer extra functionality which user can allow later. Example of using Permissions control is adding permission to send SMS or/and email to user. It is also possible to define JavaScript code which will be executed, and form id which will be submitted, after permissions are confirmed by user.

This class is member of Facebook Connect PHP Toolkit. To see all classes from the toolkit please look at the Facebook Connect Graph API classes.


Extended Permissions Popup Image

Following image shows Extended Permissions popup shown in Mozilla Firefox. In this example, permission to send SMS messages and emails is requested.

facebook extended permissions


PHP Example

The example shows adding SMS and email Facebook extended permissions using Permissions control in PHP code. After permissions are approved, it is configured that form 'form1' is submitted. This results in transfer to 'EmailSms.php' page, where extra code can be executed (for example, sending welcome messages).

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
    <head>
       <title>Facebook Extended Permissions</title>
    </head>
    <body>
      <?php
          require_once 'facebook.php';
          require_once 'faceconn/faceconn.php';
          UseGraphAPI();
      ?>
      
      <form id="form1" action="EmailSms.php">
          <?php
              $perms = new Permissions();
              $perms->SetPermissions("email, sms");
              $perms->SetOnConfirmSubmitForm("form1");
              $perms->Render();
          ?>
      </form>    
    </body>
</html>



Facebook Extended Permissions PHP class has a demo page inside Demo Website where it can be seen how it works. The most important fact is that the Demo website is contained in package with Facebook Connect PHP Toolkit which is very useful resource of code examples for each control from the toolkit. Look at the Facebook Extended Permissions Demo page.


Configuration

Configuration of the Facebook Extended Permissions PHP class is done through calls of the setter methods, which in turn set the private properties. For Facebook Extended Permissions PHP class, there is only one property which is required to be set, while all others are optional. After the configuration is set, all you have to do is to call Render() method, and the permissions control will display on the page.


Setting mandatory properties

facebook extended permissions php
Method Name
Type
Description
facebook extended permissions php
SetPermissions
String
Function sets required permissions (in comma separated list form).


Setting optional properties

facebook extended permissions php
Method Name
Type
Description
facebook extended permissions php
SetCommandType
String
Function sets the type of command control. Allowed values are 'link', 'button', 'image' and 'auto'. Default value is 'button'.
facebook extended permissions php
SetCommandText
String
Function sets the title of permissions button/link. Default value is 'Add Permissions'.
facebook extended permissions php
SetOnConfirmJavaScript
String
Function sets the JavaScript code to be executed after the permissions are confirmed.
facebook extended permissions php
SetOnConfirmSubmitForm
String
Function sets the form ID to be submitted after the permissions are confirmed.
facebook extended permissions php
SetCssStyle
String
Function sets the CSS style of the button/link.
facebook extended permissions php
SetCssClass
String
Function sets the CSS class of the button/link.
facebook extended permissions php
SetImage
String
Function sets the image of the button. Image type is set automatically.