7

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!

2

3 Answers 3

4

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

1

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.

  • no speed - a message has to hop through one additional loop (your server) before it reaches the recipient.
  • no security - browser page will communicate with your server via AJAX or forms, I assume. This means sending data as plain text (unless you're on https), open to the whole world to see (if you were to sit on a public wifi, or something like that).

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

3
  • 1
    Ok, got it. About implementation of the API: looking at the telegram-cli project, it doest look quite simple. What stages for this task (simplest case - implementation of several auth functions) would you assume? Because I've never written any API's in my career. May 28, 2015 at 9:03
  • 2
    @paus: the first few functions are the hardest, because you'll have to handle the encryption, the custom command protocol, etc. After you have this ready, the rest is pretty straightforward (regular messaging stuff, at least. Not sure about photo/video methods). Their documentation is well written. Start with this, perhaps: core.telegram.org/techfaq May 28, 2015 at 9:21
  • @SergioTulentsev its not a big deal in security . just like every other sites like twitter.com we can use ssl (https certificate ) so our communication remains secure . so you may like to edit your answer.
    – M at
    Sep 13, 2016 at 12:04
0

Now, you can use MadelineProto https://github.com/danog/MadelineProto - enought powerful PHP client for MTProto Telegram!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.