Facebook FB.ui stream.share错误

时间:2010-08-31 14:36:44

标签: facebook

我的FB.ui stream.share和stream.publish工作得很好但是当我调用Callback函数时,它总是返回错误,即使故事发布在我的Facebook个人资料中。

       [script] <div id="fb-root<?php the_ID();?>"></div>
       <script>
                window.fbAsyncInit = function() {
                FB.init({appId: '151136734905815', 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<?php the_ID();?>').appendChild(e);
         }());

       function fb_share (url, title){
         var share = {
           method: 'stream.share',
           display: 'dialog',
           u: url,
           t: title
         };

         FB.ui(share, function(response) {
          if (response && response.post_id) {
           alert(response.post_id);
           } else {
             alert('Error: Post was not published due to some error. Please try again later.');
           }

           });
       }
        </script>[/script]

始终返回错误:由于某些错误,帖子未发布。请稍后再试。即使故事在facebook上成功了。对此有何帮助?

1 个答案:

答案 0 :(得分:1)

$('#share').bind('click', function(e){
    var share = {
      method: 'stream.share',
      u: 'http://your/share/url/with/id/123'
    };
    FB.ui(share, function(){
        $.post("/log_shares.php", {"id": 123});
    });
    e.preventDefault();
});