简体   繁体   English

避免在FB.ui上确认

[英]Avoid confirmation on FB.ui

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? 请原谅我对javascript的不了解,但我有来自Facebook FB.ui的这段代码,我想知道我是否可以在按下“分享”按钮后最终避免确认? 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.');
}
  }
);

The function argument of the FB.ui method is a callback. FB.ui方法的函数参数是回调函数。 It is called when the FB.ui is done with what it is supposed to do (posting a wallpost here) FB.ui完成它应该做的事情时调用它(在这里发布一个wallpost)

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. 但是,知道FB.ui是否已成功完成它应该做的事情通常非常重要,例如检查用户是否未取消该操作。 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! 希望有所帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM