0
我正在嘗試在我的網站上放置一個Facebook Messenger'send to messenger'按鈕。到目前爲止,我一直在進行更改,偶爾會出現按鈕,但大多數情況下不會。Facebook Messenger Opt In按鈕有時只會出現
我必須加載它的代碼是在這裏:
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId: Meteor.settings.public.FacebookAppId,
xfbml: true,
version: "v2.6"
});
console.log('something in the fb init worked')
FB.Event.subscribe('send_to_messenger', function(e) {
console.log("messenger_checkbox event");
console.log(e);
if (e.event == 'rendered') {
console.log("Plugin was rendered");
} else if (e.event == 'not_you') {
console.log("User clicked 'not you'");
} else if (e.event == 'hidden') {
console.log("Plugin was hidden");
}
});
if (typeof (FB) != 'undefined'&& FB != null) { FB.XFBML.parse(); }
console.log('This then worked as well')
};
(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'));
</script>
<div class='react' id="react-root"></div>
</body>
看來FB.Event.subscribe功能沒有被稱爲要麼每當按鈕不加載。
加載實際按鈕的代碼是在這裏:
<div className="fb-send-to-messenger"
data-messenger_app_id={Meteor.settings.public.FacebookAppId}
data-page_id={Meteor.settings.public.FacebookPageId}
data-ref="PASS_THROUGH_PARAM"
data-color="blue"
data-size="standard">
</div>