skip to Main Content

Is there a way to easily import a list of contacts to telegram from desktop application?

I found contacts.importContacts method in Telegram API, but don’t understand how to use it.

3

Answers


  1. If you use TLSharp library in your desktop application, easily you can call contacts.importContacts method in this way:

    client = new TelegramClient(apiId, apiHash);
    await client.ConnectAsync();
    var result = await client.GetContactsAsync();
    

    and for example use the result variable in this way:

    var user = result.users.lists
      .Where(x => x.GetType() == typeof(TLUser))
      .Cast<TLUser>()
      .Where(x => x.first_name == textBox1.Text);
    if (user.ToList().Count != 0)
    {
        foreach (var u in user)
        await client.SendMessageAsync(new TLInputPeerUser() { user_id = u.id }, textBox1.Text);
    }
    
    Login or Signup to reply.
  2. var contactList = new TLVector<TLInputPhoneContact>();
    
                foreach (var mobile in mobileNoList)
                {
                    contactList.lists.Add(new TLInputPhoneContact { first_name = mobile.First Name, last_name = mobile.LastName, phone =  mobile.MobileNo.ToString() });
                }
    
                var req = new TLRequestImportContacts()
                {
                    contacts = contactList
                };
    
                try
                {
                    var result = await client.SendRequestAsync<TLImportedContacts>(req);
    
    Login or Signup to reply.
  3. You can try Settings -> Advanced -> Export your telegram data, in the bottom of the window you will see a JSON switch
    If you’re on Mac OS and don’t see Advanced option, then you can try Telegram Lite from Mac App Store

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search