使用 Facebook Graph 只需使用 javascript 即可发布墙消息 [英] Using Facebook Graph to simply post a wall message with just javascript
问题描述
在 Facebook 中,如何将一条消息发布到用户的墙上,上面写着我在对象游戏上的得分为 8/10"然后是 URL?
In Facebook how can I post a message onto a user's wall saying "I scored 8/10 on objects game" then a URL?
我真的不想使用完整的 API,因为我不想处理用户登录详细信息.我不介意 Facebook 是否需要进行身份验证然后发布消息.
I really don't want to have to use the full API, as I don't want to handle user login details. I don't mind if Facebook needs to authenticate and then post the message.
是否可以使用新的 Graph API 和 JavaScript?
Is it possible using the new Graph API and JavaScript?
推荐答案
Note 4/16/2011: stream.publish 似乎已被弃用,有一种新方法可以做到这一点:
Note 4/16/2011: stream.publish seems to have been deprecated, There's a new way to do this: http://developers.facebook.com/docs/reference/dialogs/feed/
您可以使用这样的方式发布到墙上,用户需要在发送前确认.不要忘记您需要使用 FB.init 并包含 JS SDK 链接.
You can use something like this to publish to a wall, the user will need to confirm before it get sent. Don't forget that you'll need to use FB.init and include the JS SDK link.
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.');
}
}
);
}
这篇关于使用 Facebook Graph 只需使用 javascript 即可发布墙消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!