Dialogs

The method FB.ui() is used to trigger different forms of Facebook created UI dialogs. These dialogs include:

  • The Share Dialog allows someone to post a link or Open Graph story to their profile.
  • The Login Dialog allows someone to use Facebook Login to grant permissions to an app.
  • The Add Page Tab Dialog allows someone to add an app to a tab on a Facebook Page which they admin.
  • The Requests Dialog allows someone to send a request to one or more of their friends from a game.
  • The Send Dialog allows someone to send a Facebook Message to one or more of their friends.
  • The Payments Dialog allows people to purchase virtual items for your app.
  • The Go Live Dialog allows people to broadcast live streaming via Facebook from your app.
FB.ui(params, function(response))

Parameters

NameTypeDescription

params

object

A collection of parameters that control which dialog is loaded, and relevant settings. Click for more info.

method

enum

The UI dialog that is being invoked. This is a required field.

*

various

Each dialog also has it's own set of additional parameters that are added to this params object when making the method call. Consult the relevant dialog's own reference doc to see the parameters that can be used.

function(response)

function

This specifies the function that is called whenever the UI dialog is closed, either by success, cancellation, or errors. The response object will depend on the dialog being used. Consult the relevant dialog's own reference doc to see the response object that should be returned. Defaults to null.

Examples

Share Dialog posting a link:

FB.ui(
  {
    method: 'share',
    href: 'https://developers.facebook.com/docs/',
  },
  // callback
  function(response) {
    if (response && !response.error_message) {
      alert('Posting completed.');
    } else {
      alert('Error while posting.');
    }
  }
);

Note that response.error_message only appears if someone using your app authenciated it with Facebook login.