trr*_*rrm 5 javascript facebook
我试图将图像发布到我的用户的Facebook墙上,一旦他们碰到了按钮
我正在使用JavaScript SDK,但我有一个问题,图像看起来像墙上的链接...但这不是我想要的...我想发布图像...与你放一个图像链接相同在您的状态文本字段上,它将变为图像
任何帮助?
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.');
}
}
Run Code Online (Sandbox Code Playgroud)
ser*_*erg 13
尝试FB.api()方法:
var wallPost = {
message : "testing...",
picture: "http://url/to/pic.jpg"
};
FB.api('/me/feed', 'post', wallPost , function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post ID: ' + response);
}
});
Run Code Online (Sandbox Code Playgroud)
您可以在此处获取支持的墙邮政索引列表(请参阅"发布").
HBK*_*HBK 12
要在用户墙上发布图像,请使用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'});
Run Code Online (Sandbox Code Playgroud)
在朋友页面上发帖:输入朋友的facebook用户ID代替"/ me".
"/"+friends_user_id+"/photos" ....
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
23923 次 |
| 最近记录: |