0

我尝试使用 FB.api 在我的墙上发布消息。但我没有得到任何回应。请你帮助我好吗。请检查我的代码一次。

function shareWithFacebook(content) {
    FB.api('/me/feed', 'post', {
        message: content
    }, function (response) {        
        if (!response || response.error) {            
            alert('Error : ' + response.error);
        } else {
            alert('Post ID: ' + response.id);            
        }
    });
    return false;
}
4

2 回答 2

1

试试这个例子

<script>
var publish = {
  method: 'feed',
  message: 'getting educated about Facebook Connect',
  name: 'Connect',
  caption: 'The Facebook Connect JavaScript SDK',
  description: (
      'A small JavaScript library that allows you to harness ' +
      'the power of Facebook, bringing the user\'s identity, ' +
      'social graph and distribution power to your site.'
  ),
  link: 'http://www.fbrell.com/',
  picture: 'http://www.fbrell.com/public/f8.jpg',
  actions: [
    { name: 'fbrell', link: 'http://www.fbrell.com/' }
  ],
  user_message_prompt: 'Share your thoughts about RELL'
};

FB.ui(publish, Log.info.bind('feed callback'));
</script>
于 2012-08-31T13:07:10.787 回答
0

您的代码没有任何问题:

FB.api('/me/feed', 'post',
        { message: content },
        function(response) {        
           if (!response || response.error) {            
               alert('Error : ' + response.error);
           } else {
               alert('Post ID: ' + response.id);            
           }
        }
);

只需确保您已通过身份验证并正确调用您的函数 shareWithFacebook。

于 2012-08-31T13:00:27.627 回答