Link Search Menu Expand Document

MadelineProto, a PHP MTProto telegram client - PHP transpiler

Created by Daniil Gentili

#StandWithUkraine 🇺🇦

Do join the official channel, @MadelineProto and the support groups!

Approved by Telegram!

What’s this?

This library can be used to easily interact with Telegram without the bot API, just like the official apps.

It can login with a phone number (MTProto API), or with a bot token (MTProto API, no bot API involved!).

It is now fully async!

Getting started (now fully async!)


if (!file_exists('madeline.php')) {
    copy('', 'madeline.php');
include 'madeline.php';

$MadelineProto = new \danog\MadelineProto\API('session.madeline');

$me = $MadelineProto->getSelf();


if (!$me['bot']) {
    // This example uses PHP 7.1+ syntax with arrays
    $MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => "Hi!\nThanks for creating MadelineProto (PHP 7)! <3"]);

    // This example uses PHP 8.0+ syntax with named arguments
    $MadelineProto->messages->sendMessage(peer: '@danogentili', message: "Hi!\nThanks for creating MadelineProto (PHP 8)! <3");

    $MadelineProto->channels->joinChannel(channel: '@MadelineProto');

    try {
        $MadelineProto->messages->importChatInvite(hash: '');
    } catch (\danog\MadelineProto\RPCErrorException $e) {

    $MadelineProto->messages->sendMessage(peer: '', message: 'Testing MadelineProto!');
$MadelineProto->echo('OK, done!');

Try running this code in a browser or in a console!

Tip: if you receive an error (or nothing), send us the error message and the MadelineProto.log file that was created in the same directory (if running from a browser).


You can find examples for nearly every MadelineProto function in