您好我正在尝试将图片发布到我的FB应用中的朋友墙上。我有这个代码,但不知道如何将图像附加到帖子。它只发布文字。有人有工作的例子吗?或者我有错误的地方?感谢。
此处图像的完整路径 - 替换为图像路径 我的FB应用程序的完整路径 - 替换为fb app的路径。
FB.ui(
{
target_id: '100000505490012',
method: 'stream.publish',
message: 'Just Testing!!!.',
attachment: {
name: 'test name',
caption: 'Caption here.',
description: (
'description here'
),
href: 'http://facebook.com/mysite'
},
media: {
type: 'image',
src: 'FULL PATH TO IMAGE HERE',
href:'FULL PATH TO MY FB APP HERE'
},
action_links: [
{ text: 'Code', href: 'FULL PATH TO MY FB APP HERE' }
],
user_prompt_message: 'Personal message here'
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);
答案 0 :(得分:1)
media属性实际上在附件属性中。
FB.ui({
target_id: '100000505490012',
method: 'stream.publish',
message: 'Just Testing!!!.',
attachment: {
name: 'test name',
caption: 'Caption here.',
description: 'description here',
href: 'http://facebook.com/mysite',
media: [{ 'type': 'image', 'src': 'FULL PATH TO IMAGE HERE', 'href':'FULL PATH TO MY FB APP HERE'}]
},
action_links: [{ text: 'Code', href: 'FULL PATH TO MY FB APP HERE' }],
user_prompt_message: 'Personal message here'
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);