I was wondering about what is the best way to know if a cell phone number has registered to the Telegram messenger or not?
Thanks.
I'm not familiar with python. but there is a way to do this:
As you know you can send a contact in telegram bot using its phoneNumber and a firsName (Doesn't need to be the real first name of the contact who owns that number).
After sending the contact to a chatID(no matter what chatID you choose, can be your own personal chat ID), you can look for its UserID.
Now if the person exists in Telegram you will get a long number that stands for his/her UserID or chatID but if not the long will be 0.
In C# I used this piece of code to see whether a phone number exists in 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());
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With