Can i get a phone number by user id via Telegram Bot API?

北城以北 提交于 2019-12-09 09:03:39

问题


I'm using Telegram Bot API for sending instant messages to users. I've installed nuget package. This package is recommend by telegram developers.

I've created a telegram bot and successfully got access to it by using code. When I send messsage to bot, bot gets some info about sender.

I need the phone numbers of users to identify them in our system and send the information back to them.

My question is Can i get a user phone number by telegramUserId ?

I'm doing it for user convenience. If i could to get a user phone number I should't have to ask for it from the user.

now my command like this:

debt 9811201243

i want

debt

回答1:


No, unfortunately Telegram Bot API doesn't return phone number. You should either use Telegram API methods instead or ask it explicitly from the user. You cannot get "friends" of a user as well.

You will definitely retrieve the following information:

  1. userid
  2. first_name
  3. content (whatever it is: text, photo, etc.)
  4. date (unixtime)
  5. chat_id

If user configured it, you will also get last_name and username.




回答2:


It's possible with bots 2.0 check out bot api docs.

https://core.telegram.org/bots/2-0-intro#locations-and-numbers https://core.telegram.org/bots/api#keyboardbutton



来源:https://stackoverflow.com/questions/33035709/can-i-get-a-phone-number-by-user-id-via-telegram-bot-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!