Answer the question
In order to leave comments, you need to log in
How to correctly send requests to Telegram API (not Bot API)?
Good afternoon.
I'm trying to send requests to the Telegram API in PHP using cURL. Important, not the Bot API, but https://core.telegram.org/api#telegram-api , in which we authorize the user.
I know that there are ready-made libraries like MadelineProto, but it has recently been updated poorly and is very cumbersome. I would like to write something simple. I only need a couple of methods for application needs.
I have a configured app, got api_id, api_hash and everything else.
I start with the basic auth.sendCode method as follows:
As the request address, I use the received server IP (both the test one and the production one), and after the slash the name of the method. Well, I think this is the most logical way. I'm probably wrong here.
$ch = curl_init('https://149.154.XXX.XXX/auth.sendCode');
curl_setopt_array($ch, array(
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => array(
'phone_number' => "+7960XXXXXXX",
'api_id' => XXXXXX,
'api_hash' => 'XXXXXXXXXXXXXXXXXXXXXXXXXX'
),
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_VERBOSE => true
));
$chresult = curl_exec($ch);
$chinfo = curl_getinfo($ch);
curl_close($ch);
Answer the question
In order to leave comments, you need to log in
There is not just an http protocol, so it cannot be easily repeated. If it is php that is interesting, then the library is advised https://github.com/danog/MadelineProto
For python, the telethon library or, alternatively, pyrogram. For js - mtproto-core. Most bot writers use python and telethon.
Googled it here:
https://stackoverflow.com/a/49581502/6705359 .
In short, you need to use TDLib.
Maybe someone can be more specific?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question