how to add contacts in telegram-cli by using vcard?

↘锁芯ラ 提交于 2019-12-08 08:10:21

问题


im trying to add my contacts in telegram-cli by using vcard. but when i use this command:

import_card <card>

nothing happen! it just goes to next line without any error and no contact added.

my vcard is VERSION:2.1

how can i improt my contacts to my telegram account by using vcard?


回答1:


Install-Package TLSharp

 client = new TelegramClient(apiId, apiHash);
    await client.ConnectAsync();
    var phoneContact = new TLInputPhoneContact() { phone = "", first_name = "", last_name = "" };
    var contacts = new List<TLInputPhoneContact>() { phoneContact };
    var req = new TeleSharp.TL.Contacts.TLRequestImportContacts() { contacts = new TLVector<TLInputPhoneContact>() { lists = contacts } };
    var rrr=     await client.SendRequestAsync<TeleSharp.TL.Contacts.TLImportedContacts>(req);



回答2:


private async Task<bool> ImportContact(string _phone , string _first_name , string _last_name)
        {
            //https://github.com/sochix/TLSharp/issues/243
            var phoneContact = new TLInputPhoneContact() { phone = _phone, first_name = _first_name, last_name = _last_name };
            var contacts = new List<TLInputPhoneContact>() { phoneContact };
            var req = new TLRequestImportContacts() { contacts = new TLVector<TLInputPhoneContact>() { lists = contacts } };
            TLImportedContacts result = await client.SendRequestAsync<TLImportedContacts>(req);
            if (result.users.lists.Count > 0)
                return true;
            else return false;
        }


来源:https://stackoverflow.com/questions/40175237/how-to-add-contacts-in-telegram-cli-by-using-vcard

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