我正在使用 Facebook JS SDK 让我的网站用户从我的网站发送 FB 消息。我定期看到以下错误:
API错误代码:100
API错误描述:参数无效
错误消息:查看者无法向指定收件人发送消息。
我很困惑,因为它并没有持续发生。更像是每 8 次尝试就有一次,没有明显的模式。有什么想法吗?
这是我的代码。首先...
<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>
然后,这是发送消息的链接:
<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>
最佳答案
您不会让用户自己选择收件人,而是尝试自己设置收件人。
如果收件人的设置不允许他接受来自“所有人”的消息,并且您的用户不是他们的 friend - 那么这正是我期望发生的情况。
关于Facebook API 错误代码 : 100 Error Message: Viewer cannot message specified recipients,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11235527/