Facebook对话框提要,不会发布到朋友墙。 JavaScript sdk

时间:2013-10-16 18:09:56

标签: facebook dialog facebook-javascript-sdk fb.ui

我试图在朋友被选中后发布到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>

我可以选择朋友,对话框显示确定,最后我的警告显示:“'帖子已发布。'”也显示,但如果我进入我朋友的墙,我仍然看不到我的帖子。 我也试过张贴到我自己的墙上,它也一样。

有什么想法吗?

由于

0 个答案:

没有答案