在Facebook中,我如何在用户的墙上发布一条消息,上面写着“我在对象游戏上得了8/10分”,然后是一个URL?
我真的不想使用完整的API,因为我不想处理用户登录的详细信息。我不介意Facebook是否需要进行身份验证,然后发布消息。
可以使用新的Graph API和JavaScript吗?
发布于 2010-05-11 09:16:24
注4/16/2011: stream.publish似乎已被弃用,有一种新的方法可以做到这一点:http://developers.facebook.com/docs/reference/dialogs/feed/
您可以使用类似这样的内容发布到墙上,用户需要在发送之前进行确认。不要忘记,您将需要使用FB.init并包含JS SDK链接。
function fb_publish() {
FB.ui(
{
method: 'stream.publish',
message: 'Message here.',
attachment: {
name: 'Name here',
caption: 'Caption here.',
description: (
'description here'
),
href: 'url here'
},
action_links: [
{ text: 'Code', href: 'action url here' }
],
user_prompt_message: 'Personal message here'
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);
}发布于 2012-11-20 21:00:39
Post on wall将显示一个对话框,用于在墙上或不墙上分享消息。但我想默默地在用户的墙上发布消息,假设用户已经授予了“在墙上发布”的权限。
FB.api('/me/feed', 'post', {
message:'my_message',
link:YOUR_SITE_URL,
picture:picture_url
name: 'Post name',
description: 'description'
},function(data) {
console.log(data);
});发布于 2011-10-05 23:53:32
考虑到您有一个代理来进行跨域调用,您可以简单地这样做...
在本例中,YourProxyMethod采用类似于散列的jQuery.ajax,进行服务器端post,并在成功/错误回调中返回响应。任何常规的代理都可以。
诀窍是在URL irself中包含app_id和access_token。此外,您的FB应用程序应该有足够的权限进行此调用。
YourProxyMethod({
url : "https://graph.facebook.com/ID/feed?app_id=APP_ID&access_token=ACCESS_TOKEN",
method : "post",
params : {
message : "message",
name : "name",
caption : "caption",
description : "desc"
},
success : function(response) {
console.log(response);
},
error : function(response) {
console.log("Error!");
console.log(response);
}
});https://stackoverflow.com/questions/2724977
复制相似问题