skip to Main Content

I am able to send a private message to my facebook friend using belwo facebook API.

<html xmlns:fb="https://www.facebook.com/2008/fbml">
<body>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<div id="fb-root"></div>
<script>
  FB.init({appId: '315462388662460', xfbml: true, cookie: true});

  FB.ui({
      method: 'send',
      link: 'https://www.youtube.com/watch?v=uia0PQy5ksg',
      });
 </script>
</body>
</html>

And everytime I run the above page it open a UI and then I have to enter my friend name and mesage and then click on Send

Since I only need to send this to just one friend, Is there any way that could just send a messge on the execution of avove script.(Without opening any UI and clicking on Send)

2

Answers


  1. the doc says that you can pass user-id of the recipient in the ‘to’ param.

    have you tried ?

    FB.ui({
          method: 'send',
          link: 'https://www.youtube.com/watch?v=uia0PQy5ksg',
          to: <user_id>
          });
    
    Login or Signup to reply.
  2. Accordingly, with the documentation, you need to provide your call with to: parameter with the id of the user, but I don’t know if this will prevent from message dialog appear

    https://developers.facebook.com/docs/sharing/reference/send-dialog

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search