Check if the user has submitted (or canceled) Facebook sharing in the Sharing dialog using FB.ui

I am using a share dialog and I want something to happen after the user has submitted something to their timeline. I am currently using:

function shareToFB(myName, myLink) {
    $('.overlay-bg').hide();
    FB.ui({
        method: 'share',
        href: myLink,
        name: myName
    }, function(response) {
        if (response && !response.error_code) {
            alert("Something");
        } else {
            alert("Error");
        }
    }
    );
}

      

But this causes "something" to appear even when the user unpubs. Is there a way I can find if the user has sent a message to their timeline without requiring any permissions. I won't mind if this requires me to use a different sharing method (like a feed dialog).

+3


source to share


2 answers


Use the Channel Dialogue instead .

Even though its UI is ugly, a successful exchange via the Feed Dialog returns a response object such as {post_id: "10206702999763274_10206703017843726"}

, no matter how the user authenticates your Facebook app or not, pressing cancel will return null

and closing the popup will return undefined

.

You can test this behavior by going to your normal Facebook user profile settings and trying to remove the app from the allowed list.

This is in contrast to the Share dialog , which, if your application has not been authenticated by the user, will return an empty response object {}

regardless of whether the exchange was successful or not.



Also, if you use the direct URL redirect method instead of the js SDK, when the user clicks the cancel button on the share page, you will get a GET error_code

and parameter error_message

appended to your redirect target.

[Since December 2015] => Use submit dialog or access dialog to access the message id in the response. To do this, the user must log into your application and provide him with publish_actions. https://developers.facebook.com/docs/sharing/reference/share-dialog#response


NOTE. This is true at the time of writing (API v2.3). However, since Facebook is known for breaking API behavior, you should test it first.

+3


source


According to the docs, the response represents a object_id

published entry - and it is only populated if the user has approved the app. This means that you cannot detect if the user really posted something if the user is not logged in.



Source: https://developers.facebook.com/docs/sharing/reference/share-dialog

+3


source







All Articles