Td: get contacts list

Created on 29 Jul 2018  路  5Comments  路  Source: tdlib/td

hi I use tdlib in java and I want to get the contacts list
I see the ImportedContacts object but which function returns this object.
I see the GetImportedContactCount function but its returns only count.

Most helpful comment

Because you have specified limit == 0 in the SearchContacts request.

All 5 comments

You need searchContacts.

tnx @levlam
I use this code:

client.send(new TdApi.SearchContacts(),object -> {
                        switch (object.getConstructor()) {
                            case TdApi.Users.CONSTRUCTOR:
                                TdApi.Users users = ((TdApi.Users) object);
                                System.out.println(users.totalCount);
                                System.out.println(users.userIds.length);
                                break;

                            default:
                                System.out.println("Receive wrong response from TDLib:" + newLine + object+ newLine+object.getClass());
                        }
                    });

this is object return:

Users {
  totalCount = 2
  userIds = Array[0] {
  }
}

why userIds is empty

Because you have specified limit == 0 in the SearchContacts request.

tnx @levlam
this is a stupid mistake from me

In TDLib 1.3.0 you can also use getContacts instead of searchContacts to get all contacts.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pishnok picture pishnok  路  3Comments

FJarvan picture FJarvan  路  3Comments

RadRussianRus picture RadRussianRus  路  3Comments

sh-a-v picture sh-a-v  路  3Comments

liaoyu1992 picture liaoyu1992  路  4Comments