javascript Facebook 使用收件人数组向多个朋友发送对话

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6469748/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 20:47:54  来源:igfitidea点击:

Facebook send dialog to multiple friends using a recipients arrays

javascriptarraysfacebook

提问by feng ma

The Facebook new Send Dialog lets people to send content to specific friends. But the API @ https://developers.facebook.com/docs/reference/dialogs/send/said the parameter 'TO' means "A user ID or username".

Facebook 新的发送对话框允许人们向特定的朋友发送内容。但是 API @ https://developers.facebook.com/docs/reference/dialogs/send/表示参数“TO”表示“用户 ID 或用户名”。

I wonder is there a method to send message to multiple friends at one time. I tried to set the 'to' as a javascript arrays, but that does not work.

我想知道有没有一种方法可以一次向多个朋友发送消息。我试图将 'to' 设置为 javascript 数组,但这不起作用。

回答by Stephen Shi

It seems that currently the sdk only takes the first element from the array that is passed to "To" parameter. This is really annoying and no formal explanation is given to this design decision. I'd wish it can take more than one uids or emails, group names etc.

似乎目前 sdk 只从传递给“To”参数的数组中获取第一个元素。这真的很烦人,并且没有对这个设计决定给出正式的解释。我希望它可以使用多个 uid 或电子邮件、组名称等。

回答by David Kinghorn

I'm not sure how you're doing it or what you define as "works", but the below kind of works:

我不确定你是如何做的,或者你定义的“作品”是什么,但以下类型的作品:

Go to the javascript test console here: https://developers.facebook.com/tools/console/And type in the following, and hit run, it will bring up a send dialog with two names prepopulated. Unfortunately, when you hit send, it goes to an error page (still trying to figure that one out). But still, it does populate the dialog with two names :P

转到此处的 javascript 测试控制台:https: //developers.facebook.com/tools/console/并输入以下内容,然后点击运行,它将弹出一个发送对话框,其中预先填充了两个名称。不幸的是,当您点击发送时,它会转到一个错误页面(仍在尝试找出那个页面)。但是,它确实用两个名称填充了对话框:P

<script>
    FB.ui(
     { 
      method: 'send', 
      to: [5,6],
      link: "https://developers.facebook.com",
      picture: "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-snc4/174597_20531316728_2866555_q.jpg"
     }, 
     function(param){
            // If they cancel params will show: 
            //    {action:false, ...}
            // and if they send the friend request it'll have:
            //    {action:true, ...}
            // and if they closed the pop-up window then:
            //    param is undefined
     }
    );
</script>

回答by Avi Kapuya

Seems both ways, direct URL and Javascript don't allow to use a list of ID's , just checked and verified it today

似乎两种方式,直接 URL 和 Javascript 不允许使用 ID 列表,今天刚刚检查并验证了它

回答by ChrisDelsart

I tried with a comma separated list of IDs, in the 'TO' field, and it worked ;)

我尝试在“TO”字段中使用逗号分隔的 ID 列表,并且它有效;)