Javascript FacebookJSSDK::如何在墙上发布图像
我试图在我的用户遇到问题时,在他们的脸书墙上贴一张图片 我正在使用javascript SDK,但我有一个问题,图像看起来像墙上的链接。。。但那不是我想要的。。。我想发布一张图片。。。与在状态文本字段上放置图像链接并将其转换为图像时相同 有什么帮助吗Javascript FacebookJSSDK::如何在墙上发布图像,javascript,facebook,Javascript,Facebook,我试图在我的用户遇到问题时,在他们的脸书墙上贴一张图片 我正在使用javascript SDK,但我有一个问题,图像看起来像墙上的链接。。。但那不是我想要的。。。我想发布一张图片。。。与在状态文本字段上放置图像链接并将其转换为图像时相同 有什么帮助吗 FB.ui( { method: 'stream.publish', message: 'test', attachment :{
FB.ui(
{
method: 'stream.publish',
message: 'test',
attachment :{
'name': 'i\'m bursting with joy',
'href': ' http://bit.ly/187gO1',
'caption': '{*actor*} rated the lolcat 5 stars',
'description': 'a funny looking cat',
'properties': {
'category': { 'text': 'humor', 'href': 'http://bit.ly/KYbaN'},
'ratings': '5 stars'
},
'media': [{
'type': 'image',
'src': 'http://icanhascheezburger.files.wordpress.com/2009/03/funny-pictures-your-cat-is-bursting-with-joy1.jpg',
'href': 'http://bit.ly/187gO1'}]
},
user_message_prompt: 'Share your thoughts about Connect'
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
尝试方法:
您可以获得受支持的墙张贴参数列表(请参阅“发布”)。要在用户的墙中张贴图像,请使用FB.api(“/me/photos”“,…)而不是FB.api(“/me/feed”“,…),此外还需要访问令牌 随附代码示例:
FB.login(function(response) {
if (response.authResponse) {
var access_token = FB.getAuthResponse()['accessToken'];
FB.api('/me/photos?access_token='+access_token, 'post', { url: IMAGE_SRC, access_token: access_token }, function(response) {
if (!response || response.error) {
//alert('Error occured: ' + JSON.stringify(response.error));
} else {
//alert('Post ID: ' + response);
}
});
} else {
//console.log('User cancelled login or did not fully authorize.');
}
}, {scope: 'publish_stream'});
要在好友页面上发布:请输入好友的facebook用户Id,而不是“/me”
但是有没有办法将图像上传到用户墙上?@From.ME.to.YOU好的,图像将作为图标而不是链接发布到墙上。这就是你需要的吗?上传是什么意思?@serg嘿,这很好用,但你能告诉我如何在朋友墙上发帖吗??我想有一个按钮,点击它可以“询问”用户是否将图片张贴在朋友的墙上。。
FB.login(function(response) {
if (response.authResponse) {
var access_token = FB.getAuthResponse()['accessToken'];
FB.api('/me/photos?access_token='+access_token, 'post', { url: IMAGE_SRC, access_token: access_token }, function(response) {
if (!response || response.error) {
//alert('Error occured: ' + JSON.stringify(response.error));
} else {
//alert('Post ID: ' + response);
}
});
} else {
//console.log('User cancelled login or did not fully authorize.');
}
}, {scope: 'publish_stream'});
"/"+friends_user_id+"/photos" ....