I have setup a share popup triggered by Jquery. It works, but I want to use the response value to trigger an AJAX call on success and Facebook only returns an empty array.
Here is the javascript
$("#fb-request").click(function () { FB.ui({ method: 'share', name: 'Check out website', href: 'URL_TO_SHARE', }, function (response) { if (response && !response.error_code) { console.log(response); // Returns: [] } }); });
Because of this I can't make the difference between someone who posts and someone who uses the cancel button. Am I missing something here? Or is there something to setup on the Facebook App?
Thanks,
From documentation:
Response Data
Parameter Description object_id Only available if the user is logged into your app using Facebook and has granted publish_actions. If present, this is the ID of the published Open Graph story.
If the user cancels the share dialog, the response is undefined, so:
$("#fb-request").click(function () {
FB.ui({
method: 'share',
name: 'Check out website',
href: 'URL_TO_SHARE',
},
function (response) {
if (response && !response.error_code) {
if (typeof response != 'undefined'){
//shered
}
}
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With