danog /MadelineProto
Async PHP client API for the telegram MTProto protocol
★ 3,553⑂ 934👁 202⑃ 485● 1,358▤ 232◈ 38
3,553
stars
934
forks
202
watchers
485
prs
1,358
issues
232
releases
38
discussions
README
MadelineProto, a PHP MTProto telegram client
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!)
php
start();
$me = $MadelineProto-getSelf();
$MadelineProto-logger($me);
if (!$me['bot']) {
$MadelineProto-messages-sendMessage(peer: '@stickeroptimizerbot', message: "/start");
$MadelineProto-channels-joinChannel(channel: '@MadelineProto');
try {
$MadelineProto-messages-importChatInvite(hash: 'https://t.me/+Por5orOjwgccnt2w');
} catch (\danog\MadelineProto\RPCErrorException $e) {
$MadelineProto-logger($e);
}
// Video call @magicalcrazypony, the MadelineProto video webradio, playing a WebM video (works on webhosts, NO ffmpeg needed!)
// See https://docs.madelineproto.xyz/docs/CALLS.html for group calls, livestreams, recording and more.
$MadelineProto-requestCall('@magicalcrazypony', video: true)-play(new \danog\MadelineProto\RemoteUrl('https://paste.daniil.it/oncall.webm'));
}
$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).
Made with MadelineProto
The following open source projects were created using MadelineProto: you can directly install them, or explore the source code as direct examples on how to use MadelineProto's many features!
magnaluna webradio - Multifeatured Telegram VoIP webradio
simpleBot.php - Extremely basic example
tgstories_dl_bot.php - Source code of @tgstories_dl_bot - Bot to download any Telegram Story!
downloadRenameBot.php - Download files by URL and rename Telegram files using this async parallelized bot!
secret_bot.php - Secret chat bot!
pipesbot.php - Creating inline bots and using other inline bots via a userbot!
bot.php - Examples for how to use filters, updates, get download links for any file, Telegram Stories and much more!
Want to add your own open-source project to this list? Click here!
Some of MadelineProto's core components are also available as separate, standalone libraries:
- danog/async-orm - Async ORM based on AMPHP v3 and fibers.
- danog/telegram-entities - A library to work with Telegram UTF-16 styled text entities.
- danog/tg-file-decoder - A library to work with Telegram bot API file IDs.
- danog/tg-dialog-id - A library to work with Telegram bot API dialog IDs.
- danog/loop - Loop/actor model abstraction for AMPHP.
- danog/better-prometheus - A better Prometheus library for PHP applications.
- danog/ipc - Async IPC component for AMPHP.
- danog/dns-over-hTop issues
#942thanks danog for this amazing piece of software24 comments · 2021-04-22#1562ParseMode3 comments · 2024-10-08#1263Using MadelineProto for private server deployments2 comments · 2022-11-29#1695Delay logic broken by parallel batching in InternalState0 comments · 2025-12-08#1680Error after updating from 8.3.1 to 8.6.00 comments · 2025-10-11#1676Worker iddle timeout0 comments · 2025-09-22
Discussions
#1758Group/video calls on webhosts!1 comments · 2026-10-17#1748Adding MadelineProto sessions at runtime1 comments · 2026-07-02#1719What's about MadelineProto v2 ?0 comments · 2026-04-04#1718TL Schema update0 comments · 2026-04-04#1699[email protected]0 comments · 2026-01-06#1630I am getting different peer_id from the same user?1 comments · 2025-04-02#1604How to get an read messsage from a Telegram group?1 comments · 2025-01-19#1574Multiple Sessions, how to stop ping loops to avoid rate limit ? Disable "magical self-restart"1 comments · 2024-11-07
Latest release
8.21.2 8.21.2 2026-11-11What's Changed Internal changes Automatic build (layer 233) by @madelineproto-autobuild[bot] in https://github.com/danog/MadelineProto/pull/1996 Bump vitest from 5.0.5 to 5.1.0 in /webui by @dependabot[bot] in https://github.com/danog/MadelineProto/pull/1998 Bump sass from 1.107.0 to 1.108.0 in /webui by @dependabot[bot] in https://github.com/danog/MadelineProto/pull/2001 Update friendsofphp/php-cs-fixer requirement from 3.95.27 to 3.95.28 in /vendor-bin/check by @dependabot[bot] in https://github.com/danog/MadelineProto/pull/1999 Bump jsdom from 30.1.3 to 31.0.0 in /webui by @dependabot