How to programmatically check if a mobile phone number is registered in the Telegram?

I was interested to know what is the best way to find out if a mobile phone number is registered in Messenger Messenger or not?

Thanks.

+5
source share
1 answer

I am not familiar with python. but there is a way to do this:

As you know, you can send a contact in a telegram using phoneNumber and firsName (it is not necessary to be the real name of the contact who owns this number).

After sending the contact to chatID (no matter which chatID you choose, it may be your personal chat identifier), you can find its UserID .

Now, if a person exists in Telegram, you will receive a long number, which means his / her UserID or chatID, but if not long, it will be 0 .

In C #, I used this piece of code to find out if the phone number exists in the telegram or not, and it worked very well.

string s = "+44...."; //the phone number var req2 = await bot.MakeRequestAsync(new SendContact(update.Message.Chat.Id, s, "Name")); if(req2.Contact.UserId == 0) { Console.WriteLine("The contact does not exist in Telegram"); }else { Console.WriteLine("The contact exists in telegram with UserID:{0}",req2.Contact.UserId.ToString()); } 
+2
source

Source: https://habr.com/ru/post/1235985/


All Articles