Facebook App Requests Dialog

Overview

The Request Dialog sends a request from one user (the sender) to one or more other users (the recipients). These requests are used to elicit a social action between users, for example “Please join my Team” in a baseball game. The Request Dialog prompts users to select one or more friends from a list and then sends requests to those friends via Facebook notifications. These notifications display in the recipient users’s Applications or Games Dashboard; they also increment a counter that is displayed next to the App bookmark in the recipient’s bookmark list (if they have the app installed). This feature does not require any extended permissions to implement and is supported via both the Graph API and the JavaScript SDK. See the Dialogs Overview for information on common options and parameters.

Note: If you are migrating from the previous Requests functionality, please keep in mind that Requests are no longer deleted when a user clicks on them. It is the Developers’s responsibility to delete a Request once it has been accepted. For more information on how to delete a request, please see the Deleting Requests section.

JavaScript Example

This example uses the JavaScript SDK to render a modal requests dialog and assumes the user has already installed the application. You must load the JavaScript SDK source and call the FB.init() method with your Application ID.

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:fb="https://www.facebook.com/2008/fbml">
  <head>
    <title>Request Tester C</title>
  </head>

  <body>
    <div id="fb-root"></div>
    <script src="http://connect.facebook.net/en_US/all.js"></script>
    <p>
      <input type="button"
        onclick="sendRequestToRecipients(); return false;"
        value="Send Request to Users Directly"
      />
      <input type="text" value="User ID" name="user_ids" />
      </p>
    <p>
    <input type="button"
      onclick="sendRequestViaMultiFriendSelector(); return false;"
      value="Send Request to Many Users with MFS"
    />
    </p>
    
    <script>
      FB.init({
        appId  : 'YOUR_APP_ID',
        status : true,
        cookie : true,
        oauth: true
      });

      function sendRequestToRecipients() {
        var user_ids = document.getElementsByName("user_ids")[0].value;
        FB.ui({method: 'apprequests',
          message: 'My Great Request',
          to: user_ids, 
        }, requestCallback);
      }

      function sendRequestViaMultiFriendSelector() {
        FB.ui({method: 'apprequests',
          message: 'My Great Request'
        }, requestCallback);
      }
      
      function requestCallback(response) {
        // Handle callback here
      }
    </script>
  </body>
</html>

Sending Requests

You can send requests to a set of users by specifying their User ID or allow a user to select the recipients using the multi-friend selector.
Send a Request to User(s)

To send a request to a single user you will need to invoke the Request Dialog with the to parameter and use it to include the User ID of the recipient user. See below:

function sendRequestToRecipients() {
  FB.ui({method: 'apprequests',
    message: 'My Great Request',
    to: '499802820'
  }, requestCallback);
}

You can pass an array or comma delimited string of User IDs to send a request to multiple users:

function sendRequestToRecipients() {
  FB.ui({method: 'apprequests',
    message: 'My Great Request',
    to: '499802820,499802852'
  }, requestCallback);
}

Send App Request
Enabling user to select the set of friends to send requests to

function sendRequestViaMultiFriendSelector() {
  FB.ui({method: 'apprequests',
    message: 'My Great Request',
  }, requestCallback);
}

Multiple selected friend

About me
Interested about Ruby on Rails

2 Responses to Facebook App Requests Dialog

  1. Michael Mazzella says:

    This created a modal request.. looks like a lightbox. is there a way to embed the friends list into your page like the old FBML?

    • me says:

      you must added code like this,

      <?php
      $friends = $facebook-&gt;api('friends.get');
      foreach ($friends as $key=&gt;$value) {
          echo count($value) . ' Friends';
          echo '<hr />';
          echo '<ul id="friends">';
          foreach ($value as $fkey=&gt;$fvalue) {
              echo '<li><img>id . '/picture" title="' . $fvalue-&gt;name . '"/&gt;</li>';
          }
          echo '</ul>';
      }
      ?>
      

Leave a reply to me Cancel reply