开发者

Problem displaying xfbml with pyfacebook

I'm using pyfacebook on my app but I'm having problems displaying xfbml For example I have to use iframes to display like buttons or like boxes.

What's strange: 1) On the login page the appears correctly, I just have problems on other pages (once logged in)

2) The FB.init part I use is

<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');

Whereas on the facebook docs the arguments are:

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) When I change the FB.init to the official fb one, application doesn't work anymore. (eg I can't logout using this

<a href="#" onclick="j开发者_开发技巧avascript:FB.Connect.logoutAndRedirect('/')">Logout</a>

I'm relatively new to FB stuff, so I'm probably mixing things up, but I just want to display correct fbml on my app without modifying too much the server side.


I think you are confusing Facebook's old javascript API with their new javascript API.

As mentioned on the new API page, use this to do the 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>

For the logout, you would want something like this:

<a href="#" onclick="javascript:FB.logout(function(response) {window.location.href = '/';})">Logout</a>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜