我正在使用Facebooker2创建一个Facebook IFrame应用程序,该应用程序作为Facebook页面中的标签运行。
我的目标是能够使用社交插件,例如类似按钮和评论等。我试着将它们定义如下
<div class="fb-like" data-href="http://www.myurl.com" data-send="false" data-layout="button_count" data-width="450" data-show-faces="false"></div>
并尝试通过调用
来初始化FB JS SDK<%= fb_connect_async_js %>
输出
<div id="fb-root"><script async="" src="http://connect.facebook.net/en_US/all.js"></script></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'APP_ID',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
oauth : true,
xfbml : true // parse XFBML
});
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>
此前已经有效,并且在Facebook推出他们上一个月前的最后一次平台更新后停止了工作。现在Like按钮根本没有渲染。我也尝试过XFBML方法,没有运气。
注意:我可以使用FB.publish发布供稿,我也可以使用IFrame方法创建一个类似按钮。
我查看了文档,但没有看到提到社交插件无法在IFrame应用程序中使用的任何地方。
任何想法?
答案 0 :(得分:0)
我遇到了同样的问题,我能找到的唯一解决方法是设置一个定时器来执行FB.XFBML.parse();
如果有人有更好的解决方案,我会非常感谢您的支持!
window.fbAsyncInit = function() {
setTimeout(function(){
FB.XFBML.parse();
FB.Event.subscribe('auth.login', function(response) {
fbLogin();
});
FB.Event.subscribe('auth.logout', function(response) {
fbLogout();
});
/* Additional initialization code here */
},
1000);
var params = {
appId : facebookAppId,
channelUrl : siteurl+'facebookChannelFile.php',
status : true,
cookie : true,
oauth : true,
xfbml : true
};
FB.init(params);
};