Facebook UI,如何检查用户是否可以向其他用户发送Facebook消息

时间:2013-03-01 07:18:38

标签: facebook facebook-graph-api facebook-javascript-sdk sendmessage

我想跟进this question。我使用FB.ui发送链接,并为一些用户得到完全相同的错误。无论如何都要检查它并决定是否向用户显示ui?

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

<a href='#' onClick="
        FB.ui({
          method: 'send',
          link: 'http://www.xxxxxxxxxxx.com',
          to: ###########,
          });
">Send a message</a>

即使我使用url send方法,某些用户也无法正常工作。例如:

错误用户:https://www.facebook.com/dialog/send?app_id=123050457758183&name=People%20Argue%20Just%20to%20Win&link=http://www.nytimes.com/2011/06/15/arts/people-argue-just-to-win-scholars-assert.html&redirect_uri=https://www.bancsabadell.com/cs/Satellite/SabAtl/&to=100000104626944

普通用户:https://www.facebook.com/dialog/send?app_id=123050457758183&name=People%20Argue%20Just%20to%20Win&link=http://www.nytimes.com/2011/06/15/arts/people-argue-just-to-win-scholars-assert.html&redirect_uri=https://www.bancsabadell.com/cs/Satellite/SabAtl/&to=1311251197

(这是从https://developers.facebook.com/docs/reference/dialogs/send/获得的共享链接示例)


错误报告给Facebook:https://developers.facebook.com/bugs/538638372825668

2 个答案:

答案 0 :(得分:2)

编辑:实际上,现在每个人都可以通过邮件联系到。它只有新的“filtering preferences”。我想这个can_message字段现在没用了,因为它应该总是返回true。我认为它会在一段时间内被弃用。


user FQL表中,您有一个必须验证所需内容的字段:

  

can_message (布尔值):用户是否可以向其他用户发送消息

来源:https://developers.facebook.com/docs/reference/fql/user

select can_message from user where uid=USER_ID

USER_ID 是您的应用用户想要向其发送消息的人。

答案 1 :(得分:-3)

您可以使用FB api;

我用的是:

FB.api('/me/permissions', function (response) 
{
//check contents of response for required permissions here
fb_publish_perm = response.data[0]['publish_stream'] ? response.data[0]['publish_stream'] : false;

if (fb_publish_perm)
{
    // it permissions exist
}
else 
{
    // permissions dont exist launch the ui to request.
}

});

请将以上视为psedo代码,因为它直接来自我的头顶!

相关问题