Facebook - Post to multiple friends walls
I am using the Javascript SDK to post something onto a users friends wall:
var publish =
{
method: 'stream.publish',
message: 'Some kind of test',
uid: uid,
target_id: friendID,
attachment: {
name: 'Test',
caption: 'Facebook API Test',
description: ('Sure hope it worked!'),
href: 'http://www.test.com/',
media: [
{
type: 'image',
href: 'http://test.com/',
src: 'http://test.com/image.jpg'
}
]
},
action_links: [
{ text: 'Enigma Marketing', href: 'http://www.test.com/' }
],
user_prompt_message: 'Share your thoughts about test'
};
FB.ui(publish);
return false;
It is working ok, but I was wondering if there was a way I could post to MULTIPLE friends walls? I notice开发者_C百科d that the pop shows a target friend in a list few, so it seems it may be possible to publish the post to more than one user. I can't find anything in the documentation, any help would be greatly appreciated.
No, you cannot post to multiple friends stream in one call.
The best way to do it is probably server side so that the user does not get multiple prompts. Notice this is usually discouraged though since it can be perceived as spam.
With your code, you can loop on just the send event part:
var publish =
{
method: 'stream.publish',
message: 'Some kind of test',
uid: uid,
attachment: {
name: 'Test',
caption: 'Facebook API Test',
description: ('Sure hope it worked!'),
href: 'http://www.test.com/',
media: [
{
type: 'image',
href: 'http://test.com/',
src: 'http://test.com/image.jpg'
}
]
},
action_links: [
{ text: 'Enigma Marketing', href: 'http://www.test.com/' }
],
user_prompt_message: 'Share your thoughts about test'
};
publish.target_id = friendID;
FB.ui(publish);
publish.target_id = friendID;
FB.ui(publish);
return false;
精彩评论