开发者

Facebook Send Dialog identify whether send or cancel has been clicked

开发者 https://www.devze.com 2023-03-20 07:37 出处:网络
I\'m using the Facebook Send Dialog to send messages to friends. As documented here: https://developers.facebook.com/docs/reference/dialogs/send/ and am using a link like the one in Facebook\'s exampl

I'm using the Facebook Send Dialog to send messages to friends. As documented here: https://developers.facebook.com/docs/reference/dialogs/send/ and am using a link like the one in Facebook's example:

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". However I've realised that you see this page even if you've clicked cancel in the Facebook dialog.

Is there any way to determine whether save or cancel has been clicked?

Update: I've found a workaround using the FB.ui method开发者_如何学C which solves the immediate issue I was having. 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.

      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'
          });

N.B. display must be set to popup for this to work!

As it does not require a redirect_uri, the issue of knowing whether save or cancel has been clicked is not an issue. If however you do wish to know this, you can access a response 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

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号