My WP site allows users to send messages to other FB users with the FB.ui() send method:
FB.ui(
method: 'send',
name: 'Bla Bla Bla',
link: 'http://www.example.com',
show_error: true,
display: 'popup'
},
function (data) {
console.log(data);
if ( data.success=true ) {
console.log('SUCCESS');
jQuery.post('http://www.example.com/wp-admin/admin-ajax.php', {
action : 'my_ajax_function',
user_id: '###',
postID : MyAjax.postID
}, function(returned) { console.log(returned); }
);
} else {
console.log('Failed to send FB invite');
};
}
);
As you can see, I’m making an AJAX call in the callback function. I’d really like that AJAX call to have access to the number of recipients who just received the message. When I log the data passed into the callback function, I don’t see any useful info besides success : true.
Anyone know of a way to retrieve the number of recipients?
And that’s only because you are setting the value of data.success yourself –
data.success=trueis not a comparison, it’s an assignment.There is no direct way of doing that, see https://developers.facebook.com/docs/reference/dialogs/send/:
You could try to find the message that the user just send via the
user/outboxconnection after asking forread_mailboxpermission – but you’d still have to figure out which message in there is the right one by looking at thecreated_timeand/ormessagecontent.