Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does one make a Telegram MTProto protocol api call?

For instance to call/wrap the auth.sentCode method (link below):

https://core.telegram.org/method/auth.sendCode

I have tried:

var url = "https://149.154.167.40";  
var data = "(auth.sendCode \"PHONE_CODE+NO\" 0 APP_ID \"SECRET_HASH\" \"en\")";  
using (var wc = new WebClient())  
{  
var result = wc.UploadData(url, GetBytes(data));  
}  

I get this exception (and inner exception)

The underlying connection was closed: An unexpected error occurred on a send. (Authentication failed because the remote party has closed the transport stream.)

like image 502
Mark Redman Avatar asked May 18 '15 17:05

Mark Redman


People also ask

How does MTProto work?

In MTProto, the clients and the server authenticate messages by ensuring that SHA-256(auth_key_fragment + plaintext + padding) = msg_key and that the plaintext always contains message length, server salt, session_id and other data not known to a potential attacker before accepting any message.

What protocol Telegram uses?

Telegram uses a custom build symmetric encryption scheme called MTProto. The protocol was developed by Nikolai Durov and other developers at Telegram and is based on 256-bit symmetric AES encryption, 2048-bit RSA encryption and Diffie–Hellman key exchange.

What is MTProto protocol?

MTProto is the Telegram Messenger protocol "designed for access to a server API from applications running on mobile devices".


1 Answers

You an get started with this SO post

You would need to understand how to generate an AuthKey first.

The Telegram-API documentation is not very well written, but if you keep studying it... you eventually get the hand of it.

Working through generating the AuthKey would help you build up a pattern and functions that you can then use to tackle the rest of the API

Cheers.

like image 185
Charles Okwuagwu Avatar answered Oct 11 '22 00:10

Charles Okwuagwu