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
Name | Type | Description |
params | object | A collection of parameters that control which dialog is loaded, and relevant settings. |
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.’);
}
}
);
response.error_message only appears if someone using your app authenciated it with Facebook login.