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.
  • The Offer Ads Dialog allows someone to create an Offer Ad using Facebook native UI without leaving your app.
  • The Leadgen Dialog allows someone to create a Leadgen Form using Facebook native UI without leaving your app.
  • The Canvas Ads Dialog allows someone to create a Canvas Ad using Facebook native UI without leaving your app.
  • The Collection Ads Dialog allows someone to create a Collection Ad using Facebook native UI without leaving your app.
  • The Canvas Preview Dialog allows someone to preview a Canvas or Collection Ad as it would be seen by a user on Facebook without leaving your app.
FB.ui(params, function(response))

Parameters

Name Type Description

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.