I realize it is not possible to use a Bot
to receive a sender’s phone number.
I do, however, need to implement a bot-like client, that responds to anyone who is messaging it. I am using PHP on apache.
It is not a Bot, as it does not take commands, but rather responds to sent text from anyone who has that phone number. So you add the user as a contact (using a phone number), and then send text to it.
My goal is to realise the sender’s phone number as I receive it, I saw on the Telegram API that there’s a peer ID, but I can’t find how to get the phone number if that’s even possible…
2
Answers
try this lib from github https://github.com/irazasyed/telegram-bot-sdk
and code to create ‘visit card’ button in private chat:
and code to get unic user phone from ‘visit card’ after user push the button
finally i found how to get the phone number.
I use package https://github.com/irazasyed/telegram-bot-sdk for Laravel 8.
The code below is command to send button and when user press the button, it’ll catch the phone number from user after the user click on "share".
PhoneNumberCommand.php
ControllerWebhook.php
It’s work for me! hope you can implement too.