1

I know we can publish something on a friend's wall with this:

$publishStream = $facebook->api("/$user/feed", 'post', array(
     'message' => "Your Message", 
     'link'    => 'http://example.com',
     'picture' => '',
     'name'    => 'App Name',
     'description'=> 'App description'
));

Just by replacing the $user variable with the user id of your friend.

What i wish is simply to choose among my friends, the user profiles i want to write on using check boxes.

this is something already possible if you want to share a fan page for instance. You choose the persons you send the request to.

Thanks in advance for your help

  • 1
    Writing to News Feeds *en masse* would probably be considered spam. Consider using the Requests system instead: https://developers.facebook.com/docs/reference/dialogs/requests/ – Cal McLean Sep 11 '12 at 15:24
  • And is it possible to send notifications before the messages are written on the walls ? –  Sep 11 '12 at 15:29
  • 2
    It is, but that's working around the problem, rather than facing it. The feed is not intended to be used in such a way. If you want a user to be able to send a message to multiple users, use the Requests system, not the Feed. – Cal McLean Sep 11 '12 at 15:31

1 Answers1

1

You can use Facebook's Multi-Friend-Selector (MFS). https://developers.facebook.com/docs/guides/games/custom-muti-friend-selector/

An edited example taken from the Multi-Friend-Selector documentation

function renderMFS() {
 // First get the list of friends for this user with the Graph API
 FB.api('/me/friends', function(response) {
   var container = document.getElementById('mfs');
   var mfsForm = document.createElement('form');
   mfsForm.id = 'mfsForm';

   // Iterate through the array of friends object and create a checkbox for each one.
   for(var i = 0; i < Math.min(response.data.length, 10); i++) {
     var friendItem = document.createElement('div');
     friendItem.id = 'friend_' + response.data[i].id;
     friendItem.innerHTML = '<input type="checkbox" name="friends" value="'
       + response.data[i].id
       + '" />' + response.data[i].name;
       mfsForm.appendChild(friendItem);
     }
     container.appendChild(mfsForm);

     // Extract selected friends' Facebook ID from value property of checked checkboxes

     // Do a for loop to send notification (refer to the link posted below) and publish post to each user's wall
   });
 }

And is it possible to send notifications before the messages are written on the walls?

Yes it is possible when you have the Facebook ID. Refer to my answer in How to send Facebook message to friend using Facebook ID?

Community
  • 1
  • 1
Mysophobe
  • 622
  • 2
  • 10
  • 33