如何以编程方式检查手机号码是否已在 Telegram 中注册? [英] How to programmatically check if a cell phone number is registered in the Telegram?

查看:71
本文介绍了如何以编程方式检查手机号码是否已在 Telegram 中注册?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道知道手机号码是否已注册到 Telegram Messenger 的最佳方法是什么?

I was wondering about what is the best way to know if a cell phone number has registered to the Telegram messenger or not?

谢谢.

推荐答案

我不熟悉 python.但有一种方法可以做到这一点:

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

如您所知,您可以使用 phoneNumberfirsName 在电报机器人中发送联系人(不必是拥有联系人的真实姓名)那个数字).

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).

将联系人发送到某个chatID(无论您选择什么chatID,都可以是您自己的个人聊天ID)后,您可以查找其UserID.

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.

现在如果这个人存在于 Telegram 中,你会得到一个很长的数字代表他/她的用户 ID 或聊天 ID,但如果不是,则长度为 0.

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.

在 C# 中,我使用这段代码查看电报中是否存在电话号码,并且效果很好.

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());
}

这篇关于如何以编程方式检查手机号码是否已在 Telegram 中注册?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆