使用FB.api在Facebook上发布消息
Post a message in Facebook with FB.api
我试着用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;
}
试试这个例子
<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>
您的代码没有任何问题:
FB.api('/me/feed', 'post',
{ message: content },
function(response) {
if (!response || response.error) {
alert('Error : ' + response.error);
} else {
alert('Post ID: ' + response.id);
}
}
);
只需确保您已通过身份验证,并正确调用您的函数shareWithFacebook即可。
相关文章:
- Ajax聊天消息重复而不仅仅是更新
- 如果localstorage为空,则显示欢迎消息
- 绑定时将Parsley minlength消息作为选项传递时,未对其进行自定义
- 离开页面时弹出消息
- 有没有一种方法可以在控制台关闭的情况下让console.log()在IE中记录消息
- 消息显示之外的淘汰验证
- 选项卡侦听器未被来自后台脚本的消息激活
- jQuery在输入下验证post错误消息
- Scipt未在选定选项卡中执行以发送和接收消息
- 检查xmlhttprequest问题的消息
- AngularJs对ng消息的自定义替换
- ng消息仅在触摸时显示错误,并在错误的初始显示上转换
- 当用户按下回车键时,自动在text区域/text中插入消息
- 如果消息框答案为YES,则用Javascript填写表单
- 在javaservlet doPost方法中启动线程时,无法返回异常消息
- 解析云代码错误:解析.错误{代码:141,消息:“未调用成功/错误”}
- Node.js上的WebSocket,并在所有连接的客户端之间共享消息
- 在AngularJs中隐藏默认错误消息
- 使用JavaScript安全地发布消息
- Rails:如何向用户预加载消息