0

选择朋友后,我试图发布到 Facebook 朋友墙上。我使用来自https://codersgrave.com/的朋友选择器

我有这个代码:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Facebook Friend Selector Basic Example - Coders' Grave</title>

<!-- Add Facebook Friend Selector CSS -->
<link type="text/css" href="friend-selector/jquery.friend.selector-1.2.1.css" rel="stylesheet" />

<!-- Add jQuery library -->
<script type="text/javascript" src="js/libs/jquery-1.6.2.min.js"></script>

<!-- Add Facebook Friend Selector JS -->
<script type="text/javascript" src="friend-selector/jquery.friend.selector-1.2.1.js"></script>

<!-- Friend Selector Integration  -->
<script type="text/javascript">

  jQuery(document).ready(function($) {
    var id = 0;
    $(".bt-fs-dialog").fSelector({
       max: 1,
       onSubmit: function(response){         
       id = response[0];
       alert(id);
       FB.ui({
  method: 'feed',
  link: 'https://developers.facebook.com/docs/dialogs/',
  caption: 'My text',
  to: id, 
},
function(response) {
    if (response && response.post_id) {
      alert('Post was published.');
    } else {
      alert('Post was not published.');
    }
  });
      }
    });    
  });
</script>

</head>
<body>

<!-- Facebook Integration  -->
<script src="http://connect.facebook.net/en_US/all.js"></script>
<div id="fb-root"></div>
<script type="text/javascript">
  window.fbAsyncInit = function() {
    FB.init({
      appId             : '1399631740271365', // Facebook Application ID
      status            : true, // check login status
      cookie            : true, // enable cookies to allow the server to access the session
      xfbml             : true, // parse XFBML     
    });


    FB.getLoginStatus(function(response) {
      if (response.authResponse) {
        $(".connect").attr("class", "logout").text("Logout");
        $(".fs-dialog-container").show();

        $(".logout").click(function(){
          FB.logout(function(response) {
            location.reload();
          });
        });

      } else {

      }
    });

  };

  // Load the SDK Asynchronously
  (function(d){
     var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
     js = d.createElement('script'); js.id = id; js.async = true;
     js.src = "//connect.facebook.net/en_US/all.js";
     d.getElementsByTagName('head')[0].appendChild(js);
   }(document));


  jQuery(document).ready(function($){

    $(".connect").click(function(){
      FB.login(function(response) {
        if (response.authResponse) {
          location.reload();
        } else {
          // User cancelled login or did not fully authorize
        }
      }, {scope: 'user_groups'});
    });

  });

</script>


<a href="#" class="connect">Connect</a>
<br />
<a href="#" class="bt-fs-dialog">Click here</a>

</body>
</html>

我可以选择朋友,对话框显示ok,最后我的警报显示:“'帖子已发布。'”也显示,但如果我进入我朋友的墙,我仍然看不到我的帖子。我也尝试过在自己的墙上发帖,结果是一样的。

有任何想法吗?

谢谢

4

0 回答 0