我试图使用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;
}
答案 0 :(得分: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>
答案 1 :(得分: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。