I can't figure out what exactly to use for interaction between my site and the Telegram service (first of all - how to get the authentication process done using PHP and other stuff like chat among users).
On this page: https://core.telegram.org/api I haven't got an idea how to use those functions in PHP.
According to this page: https://telegram.org/apps I have two choices:
1) The CLI-interface (unofficial, by the way): https://github.com/vysheng/tg and it doesn't have an autentification function among others. In order to authenticate yourself, you need to run:
bin/telegram-cli -k tg-server.pub
and inside of the application you have to enter your cell phone and the secret code sent by SMS - after that you're authorized. Then you install https://github.com/zyberspace/php-telegram-cli-client and run telegram-cli as a daemon:
./bin/telegram-cli -dWS /tmp/tg.sck -k tg-server.pub &
Does it mean that I have to create tg-server.pub manually using PHP for each user which is trying to login?
2) Webogram: https://github.com/zhukov/webogram - but it's written on JavaScript and has very complicated code.
Dear Stackoverflow gurus, maybe you're more attentive than I am and could help me to recognize the right solution (or example, I don't know, the PHP snippet or anything else) for the user's chat based on the Telegram and PHP?
I would greatly appreciate it!
Thank you!
To send a message to the Telegram channel use the following PHP script example: <? php $apiToken = "5082654068:AAF7quCLZ4xuTq2FBdo3POssdJsM_FRHwTs"; $data = [ 'chat_id' => '515382482', 'text' => 'Hello from PHP! ' ]; $response = file_get_contents("https://api.telegram.org/bot$apiToken/sendMessage?" .
It is NOT possible for a bot to send messages to a phone number. As far as I know, it is also NOT possible to send to a @username , unless it is a @channel_username . A bot sends messages by user_id . It can know your user_id only if you have send it a message first.
I have posted a step by step guide on getting your AuthKey (VB.net) here
The main challenge with Telegram API is the documentation... but if you can work through the first part - getting an AuthKey then i believe the rest should fall in place ... with some more effort.
Working through some GitHub src might be time consuming, it might be best to get a handle on the documentation and then work your way to building your own code for TelegramAPI from scratch
Most likely, PHP wrapper for Telegram API doesn't exist. I'd wager it's because communicating with Telegram servers from your server-side PHP code defeats both of the core features of Telegram: speed and security.
You can implement the Telegram API, it's a bit involved, but doable. But it's totally pointless, in my opinion.
As an alternative, just embed the webogram in an <iframe>
or something :)
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