我尝试将应用程序中的图像发布到墙上。我希望图像能看到其原始大小,而不是像小图片。
我尝试了两种方法,但都不起作用。
FB.ui(
{
target_id:'ID',
method: 'stream.publish',
access_token:accessToken,
attachment: {
name: 'test name',
caption: 'Caption here.',
description: 'description here',
href: 'http://facebook.com/mysite',
media: [{'type': 'image', 'src': pic, width: '150', height: '120', 'href': 'MY_SITE'}]
},
message: '',
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
console.log(response);
alert('Post was not published.');
}
}
);
这会将图像发布到我的墙上,但它是一张小图片。我尝试将图像发布到我的相册中,如下所示:
FB.api('me/photos', 'post',
{
url:'MY_URL',
href:'MY_LINK,
message: 'photo description',
access_token:accessToken
},
function(response) {
console.log(response);
if (!response || response.error) {
alert('Error occurred');
} else {
alert('Post ID: ' + response.id);
}
});
但是图像没有显示在我的墙上。它在我的相册中,但我需要单击“批准照片”。单击后,它就会显示在我的墙上。
我的问题是:如果我使用第一个代码,有没有办法让图像以其原始大小显示?
如果我使用第二个代码,如何让它自动从我的相册发布到我的墙上?
最佳答案
向“我/照片”发帖将为您的应用创建一个新相册并在那里发布照片。您可以考虑创建一个新相册或上传到现有相册,并让 Facebook 处理照片在新闻源中向好友显示的大小。看看这篇描述您需要什么的博客文章。这是一个 php
示例,但 API 调用在 JavaScript
中是相同的 https://developers.facebook.com/blog/post/498/
关于facebook - 使用 javascript api 在我的墙上发布一张大图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11097050/