Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook Send Dialog identify whether send or cancel has been clicked

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 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.

like image 389
Andy Avatar asked Jul 15 '11 10:07

Andy


2 Answers

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
              }
          });
like image 177
Andy Avatar answered Oct 25 '22 02:10

Andy


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
}
like image 33
Pontus Hymér Avatar answered Oct 25 '22 04:10

Pontus Hymér