Facebook API Error code: 100 Error Message: Viewer cannot message specified recipients

末鹿安然 提交于 2019-12-11 02:22:34

问题


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>

回答1:


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.



来源:https://stackoverflow.com/questions/11235527/facebook-api-error-code-100-error-message-viewer-cannot-message-specified-reci

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!