Reputation: 26567
This is my code:
window.fbAsyncInit = function() {
FB.init({
appId: "xxx",
xfbml: true,
version: "v2.6"
});
FB.Event.subscribe('send_to_messenger', function(response) {
// callback for events triggered by the plugin
console.log('inside the send_to_messenger');
if ( response.event == 'clicked' ) {
};
});
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) { return; }
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
So now, how do I get the PSID of the user ?
Upvotes: 3
Views: 1475
Reputation: 2848
You need to subscribe to the messaging_optins
webhook event. When the send to messenger button is clicked, you should get the PSID in sender.id
prop of the event.
Upvotes: 2