Stars: 2459
Forks: 606
Pull Requests: 186
Issues: 1155
Watchers: 153
Last Updated: 2023-09-16 17:49:39
Async PHP client API for the telegram MTProto protocol
License: GNU Affero General Public License v3.0
Languages: PHP, Shell, Dockerfile
Created by Daniil Gentili
#StandWithUkraine 🇺🇦
Do join the official channel, @MadelineProto and the support groups!
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!).
<?php
if (!file_exists('madeline.php')) {
copy('https://phar.madelineproto.xyz/madeline.php', 'madeline.php');
}
include 'madeline.php';
$MadelineProto = new \danog\MadelineProto\API('session.madeline');
$MadelineProto->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);
}
}
$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).
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!
simpleBot.php
- Extremely basic exampletgstories_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!
$MadelineProto->start()
- The web template used for the $MadelineProto->start() and API ID web UIs can be changed.