Search code examples
facebookdialogfeed

"TO" parameter << feed dialog on Facebook


I have a little trouble. I'm using the script, which is below. The problem is here, that i need to make that when i click on "post" button, there must popup the list of my friends and i have to choose one. I cant solve this, tried by chaning "to" parameter to blank and many other ways.

Thank you. Here is the code:

        <html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:fb="https://www.facebook.com/2008/fbml">
  <head>
    <title>My Feed Dialog Page</title>
  </head>
  <body>
    <div id='fb-root'></div>
    <script src='http://connect.facebook.net/pl_PL/all.js'></script>
    <p><a onclick='postToFeed(); return false;'>Post to Feed</a></p>
    <p id='msg'></p>

    <script> 
      FB.init({appId: "asdasdasdasd", status: true, frictionlessRequests : true, cookie: true});

      function postToFeed() {

        // calling the API ...
        var obj = {
          method: 'feed',
          to: '100001987316260',

          link: 'asdasdasdasdl',
          picture: 'http://fbrell.com/f8.jpg',
          name: 'Nazwa',
          caption: 'Podnazwa',
          description: 'gówno gówno gówno gówno gówno gówno gówno.'
        };

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

        FB.ui(obj, callback);
      }

    </script>
  </body>
</html>

Solution

  • Unfortunately there is no way to have friend selector in feed dialog

    The closest behavior you can get here is by using stream.share or send dialog instead

    stream.share is used for sharing a URL (the data is read from the og metadata on the url) - the information on the "post" can't be set by you - but the user have the option to select a friend and post on his timeline

    <script>
    var share = {
      method: 'stream.share',
      u: 'http://LINK.TO/SHARE/'
    };
    
    FB.ui(share, callback_function);
    </script>
    

    send is used to send a link to friend/group/email as a private message. an example for use:

    <script>
    var publish = {
      method: 'send',
      link: 'http://LINK.TO/SHARE'
    };
    
    FB.ui(publish, callback_function);
    </script>