Facebook messenger复选框插件被隐藏 [英] Facebook messenger checkbox plugin is hidden
问题描述
我正在尝试以一种形式实现新的Facebook Checkbox插件,但是在屏幕上无法让它显示出奇怪的方式。所以我没有客户端错误,但是iframe是隐藏的。
I'm trying to implement the new Facebook Checkbox plugin in a form but in a weird way I can't get it showing on the screen. So I don't get errors clientside but Iframe is hidden.
以下是代码的简化示例:
Here's an simplified example of the code:
<html>
<head>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '1815704925309469',
xfbml : true,
version : 'v2.6'
});
FB.Event.subscribe('messenger_checkbox', function(e) {
console.log("messenger_checkbox event");
console.log(e);
if (e.event == 'rendered') {
console.log("Plugin was rendered");
} else if (e.event == 'checkbox') {
var checkboxState = e.state;
console.log("Checkbox state: " + checkboxState);
} else if (e.event == 'not_you') {
console.log("User clicked 'not you'");
} else if (e.event == 'hidden') {
console.log("Plugin was hidden");
}
});
};
(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')
);
function confirmOptIn() {
FB.AppEvents.logEvent('MessengerCheckboxUserConfirmation', null, {
'app_id':'1815704925309469',
'page_id':'1711063052543482',
'ref':'shopping-cart-company',
'user_ref':'1234'
});
}
</script>
<div class="col-md-7">
<div class="fb-messenger-checkbox"
origin=https://shopping-cart-company.herokuapp.com/index.html
page_id=1711063052543482
messenger_app_id=1815704925309469
user_ref="1234"
prechecked="true"
allow_login="true"
size="large">
</div>
</div>
<body>
<input type="button" onclick="confirmOptIn()" value="Confirm Opt-in"/>
</body>
在开发控制台中没有错误。只有插件被隐藏的日志:
There are no errors in the dev console. Only logs that the plugin is hidden:
推荐答案
Facebook更新了他们的 docs :
Facebook updated their docs:
网络插件需要一个
user_ref
参数,作为用户的标识符。当用户完成流程时,我们将把此标识符传回给您来识别用户。这个参数应该是唯一的,不仅仅是为每个用户,而是每次插件被呈现时。如果参数不是唯一的,那么插件可能无法渲染。
The web plugin takes a
user_ref
parameter which is used as an identifier for the user. When the user finishes the flow, we will pass this identifier back to you to identify the user. This parameter should be unique not just for every user, but for every time the plugin is rendered. If the parameter is not unique, then the plugin may not render.
您必须生成一个新的 user_ref
You have to generate a new user_ref
for every single render of the checkbox plugin.
显示CheckBox插件的清单
-
使用生产应用程序标识(不是测试用例) - 始终重新生成
user_ref
- 将
原产地的域名列入白名单
- 使用
来源的正确协议
- http / https
use Production App Id (not the test one)- always regenerated
user_ref
- whitelist the domain in
origin
- use correct protocol in
origin
- http / https
这篇关于Facebook messenger复选框插件被隐藏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!