Search code examples
phpjavascriptfacebookfeed

Posting a story/message to multiple friends' feed/Wall


I have the following JavaScript code to publish/post a message to friend's Wall, as this code publishes to only one friend's Wall. What I am trying to do is, to publish/post one message to multiple friends' Wall. Any help please...!

  function postToFeed() {

    // calling the API ...
    var obj = {
      method: 'feed',
      link: 'https://developers.facebook.com/docs/reference/dialogs/',
      picture: 'http://fbrell.com/f8.jpg',
      name: 'Facebook Dialogs',
      caption: 'Reference Documentation',
      description: 'Using Dialogs to interact with users.',
      to: 'FRIND_ID'
    };

    function callback(response) {
      document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
    }

    FB.ui(obj, callback);
  }

Solution

  • As far as I'm aware that's not possible with the js sdk, unless of course you want to open a dialog per post...

    You can however ask for the *publish_stream* and then make the posts on the server side, there you can issue as many posts as you want. Here too you'll be able to send one post at a time, but you can do it more than once without bothering the user with a dialog for every post.

    EDIT

    The documentation for permissions: http://developers.facebook.com/docs/reference/api/permissions/ states:

    publish_stream

    Enables your app to post content, comments, and likes to a user's stream and to the streams of the user's friends. With this permission, you can publish content to a user's feed at any time, without requiring offline_access. However, please note that Facebook recommends a user-initiated sharing model.

    As for how to do it actually, you tagged this question as "php", and so you should use the facebook php sdk, with that it's pretty simple and straight forward how to do it, and you have the official tutorial: http://developers.facebook.com/docs/reference/php/facebook-api/ (go to the Post a link to a User's wall using the Graph API)

    Hope this is clear enough.