与pyfacebook显示XFBML的问题
-
29-09-2019 - |
题
我在应用程序上使用PYFACEBOOK,但是在显示XFBML时遇到问题,例如,我必须使用iframes来显示按钮或类似的框。
奇怪的是:1)在登录页面上出现正确,我只是在其他页面上有问题(一旦登录)
2)fb。我使用的部分是
<script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/en_US" type="text/javascript"></script>
<script type="text/javascript">FB.init("{{ apikey }}", '/static/xd_receiver.html');
而在Facebook文档中,论点是:
FB.init({
appId : 'YOUR APP ID',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
3)当我将fb.init更改为官方fb One时,应用程序不再起作用。 (例如,我无法使用此注销
<a href="#" onclick="javascript:FB.Connect.logoutAndRedirect('/')">Logout</a>
我对FB的东西相对较新,因此我可能会混合使用,但是我只想在我的应用程序上显示正确的FBML,而不会过多地修改服务器端。
解决方案
我认为您正在混淆Facebook的 旧的JavaScript API 和他们的 新的JavaScript API.
如新API页面上所述,使用此功能来完成INIT:
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({appId: 'your app id', status: true, cookie: true,
xfbml: true});
};
(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>
对于注销,您需要这样的东西:
<a href="#" onclick="javascript:FB.logout(function(response) {window.location.href = '/';})">Logout</a>
不隶属于 StackOverflow