简体   繁体   English

Facebook 发送对话框识别是否点击了发送或取消

[英]Facebook Send Dialog identify whether send or cancel has been clicked

I'm using the Facebook Send Dialog to send messages to friends.我正在使用 Facebook Send Dialog 向朋友发送消息。 As documented here: https://developers.facebook.com/docs/reference/dialogs/send/ and am using a link like the one in Facebook's example:如此处所述: https://developers.facebook.com/docs/reference/dialogs/send/并使用类似于 Facebook 示例中的链接:

https://www.facebook.com/dialog/send?app_id=123050457758183&name=People%20Argue%20Just%20to%20Win&link=http://www.nytimes.com/2011/06/15/arts/people-argue-just-to-win-scholars-assert.html&redirect_uri=http://www.example.com/response

On the page I have specified as the redirect_uri I am displaying text saying: "Your message has been sent".在我指定为redirect_uri的页面上,我显示的文字是:“您的消息已发送”。 However I've realised that you see this page even if you've clicked cancel in the Facebook dialog.但是,我意识到即使您在 Facebook 对话框中单击了取消,您也会看到此页面。

Is there any way to determine whether save or cancel has been clicked?有什么方法可以确定是否单击了保存取消

Update: I've found a workaround using the FB.ui method which solves the immediate issue I was having.更新:我找到了使用 FB.ui 方法的解决方法,该方法解决了我遇到的直接问题。 I would still be interested to know if anyone has a better solution using a Send Dialog link like the one above.我仍然很想知道是否有人使用上面的发送对话框链接有更好的解决方案。

I've found a work around by using Facebook's Javascript SDK's FB.ui method.我通过使用 Facebook 的 Javascript SDK 的 FB.ui 方法找到了解决方法。

      FB.ui({
          method: 'send',
          name: 'People Argue Just to Win',
          link: 'http://www.nytimes.com/2011/06/15/arts/people-argue-just-to-win-scholars-assert.html,
          display: 'popup'
          });

NB display must be set to popup for this to work! NB 显示必须设置为弹出才能正常工作!

As it does not require a redirect_uri , the issue of knowing whether save or cancel has been clicked is not an issue.由于它不需要redirect_uri ,因此知道是否单击了保存或取消的问题不是问题。 If however you do wish to know this, you can access a response object:但是,如果您确实想知道这一点,可以访问响应 object:

      FB.ui({
          method: 'send',
          name: 'People Argue Just to Win',
          link: 'http://www.nytimes.com/2011/06/15/arts/people-argue-just-to-win-scholars-assert.html,
          display: 'popup'
          },
          function(response) {
              if (response){
                  // save has been clicked
              } else {
                  // cancel has been clicked
              }
          });

Small complement to Andy's response: the response-object does not give much info about what has been sent, actually (returns [] in console), but the mere EXISTENCE of the reponse object indicates the "SEND" button has been pressed对安迪的响应的小补充:响应对象实际上并没有提供有关已发送内容的太多信息(在控制台中返回 []),但仅存在响应 object 表示已按下“发送”按钮

FB.ui(obj, function (param) {
if (param) {
// The "SEND" button has been pressed
}
else{
// The "Cancel" button has been pressed
}

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

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