2

I'm using the Facebook JS SDK to let my site's users send FB messages from my site. I periodically see the following error:

API Error Code: 100
API Error Description: Invalid parameter
Error Message: Viewer cannot message specified recipients.

I'm confused because it doesn't happen consistently. It's more like once in every 8 attempts, with no apparent pattern. Any ideas?

Here's my code. First...

<script>
      window.fbAsyncInit = function() {
        FB.init({
          appId      : '##########', // App ID
          channelUrl : '//www.xxxxxxxxxx.com/channel.php', // Channel File
          status     : true, // check login status
          cookie     : true, // enable cookies to allow the server to access the session
          xfbml      : true  // parse XFBML
        });

        // Additional initialization code here
      };

      // Load the SDK Asynchronously
      (function(d){
         var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
         if (d.getElementById(id)) {return;}
         js = d.createElement('script'); js.id = id; js.async = true;
         js.src = "//connect.facebook.net/en_US/all.js";
         ref.parentNode.insertBefore(js, ref);
       }(document));
    </script>

Then, here's the link to send the message:

<a href='#' onClick="
        FB.ui({
          method: 'send',
          name: 'Bla bla bla',
          link: 'http://www.xxxxxxxxxxx.com',
          to: ###########,
          //redirect_uri: 'http://www.xxxxxxxxxxx.com/fb/'
          });
        ">Send a message</a>
emersonthis
  • 32,822
  • 59
  • 210
  • 375

1 Answers1

2

You’re not letting the user chose the recipient(s) themselves, but try to set them yourself.

If the recipient has his settings so that he doesn’t accept messages from “everyone”, and your user is not a friend of theirs – then that’s exactly what I would expect to happen.

CBroe
  • 91,630
  • 14
  • 92
  • 150
  • 1
    AHA! I overlooked the fact that users could refuse messages from "friends of friends". It doesn't help that FB sometimes throws a different error message for the same problem. It's always error code 100, but sometimes it adds the message, and other times it's generic. Here's the million-dollar follow-up question: Is there anything I can do from my side to spare the user of that nasty error message? For example, is there a way to pre-test to see if the recipient allows messages? – emersonthis Jun 28 '12 at 19:32
  • You were 100% right about the error above (thanks as always), but it turns out my client is actually seeing a different error that is much more mysterious. I posted a new question here: http://stackoverflow.com/questions/11254347/fb-ui-fails-with-error-invalid-url-but-not-always-rrrggg – emersonthis Jun 28 '12 at 23:37
  • 1
    Did you find a way to check whether or not you can message ? – w00d Feb 28 '13 at 23:21