Question

Please excuse my lack of knowledge of javascript, but I have this code from Facebooks FB.ui and I was wondering if I can avoid the confirmation at the end after pressing the 'Share' button? I just want the popup to close after the user presses share with no confirmation either way. Is this possible? If so, how do I modify the code? Thank you in advance.

FB.ui(
  {
method: 'feed',
name: 'Facebook Dialogs',
link: 'https://developers.facebook.com/docs/dialogs/',
picture: 'http://fbrell.com/f8.jpg',
caption: 'Reference Documentation',
description: 'Dialogs provide a simple, consistent interface for applications to interface with users.'
  },
  function(response) {
if (response && response.post_id) {
  alert('Post was published.');
} else {
  alert('Post was not published.');
}
  }
);
Was it helpful?

Solution

The function argument of the FB.ui method is a callback. It is called when the FB.ui is done with what it is supposed to do (posting a wallpost here)

To get rid of the confirmation, you just need to get rid of the callback or letting it empty. However it is usually very important to know if the FB.ui has succeeded in doing what it is supposed to do, for example to check if the user hasn't cancelled the action. That's why the callbacks are there. You can turn them into whatever you need though. In any case the dialog will be closed.

FB.ui({
  method: 'feed',
  name: 'Facebook Dialogs',
  link: 'https://developers.facebook.com/docs/dialogs/',
  picture: 'http://fbrell.com/f8.jpg',
  caption: 'Reference Documentation',
  description: 'Dialogs provide a simple applications to users interface.'
},
function(response) {
  if (response && response.post_id)
    // Do whatever you need if the post is successfull
  else
    // Do whatever you need if the post failed
});

Hope that helped!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top