繁体   English   中英

whatsapp-web.js,如何向某人发送其他人的名片?

[英]whatsapp-web.js, how do I send someone a contact card of someone else?

如何在 whatsapp-web.js 中向某人发送其他人的名片? 发名片的人保存在手机上,但我要发的联系人不在手机通讯录里,能发名片吗

client.on('ready', async () => {   try {
    console.log('Client is ready!');
    const saved = [];

    var array = fs.readFileSync('numb.txt').toString().split("\n"); //reading file
    for (i in array) {
      //console.log(array[i]);
      saved.push(array[i].substring(1)); //array with number 
    }

    const contacts = [];
    for (var i = 0; i < saved.length; i++) {
      contacts.push(await client.getContactById(saved[i] + '@c.us')); }
    client.sendMessage(to, contacts); //sending contact cards   
} });

您可以通过将电子名片作为短信发送来发送。

例子:

client.on('ready', async () => {
    client.sendMessage(
        '1234567890@c.us', 
        'BEGIN:VCARD
          ....(vcarddata)....
        END:VCARD', 
        {'parseVCards':true}) // by default its true
     .then(...).catch(...);
});

VCard 将通过 parseVCard 选项进行解析和联系。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM