Async PHP client/server API for the telegram MTProto protocol
https://docs.madelineproto.xyz
.vscode | ||
docs | ||
fuzz | ||
lua | ||
old_docs | ||
src | ||
tests | ||
userbots | ||
.babelrc | ||
.env.calls | ||
.env.example | ||
.gitignore | ||
.travis.yml | ||
bot.php | ||
build_docs_index.php | ||
build_docs.php | ||
CHANGELOG.md | ||
CODE_OF_CONDUCT.md | ||
composer.json | ||
CONTRIBUTING.md | ||
index.php | ||
input.raw | ||
LICENSE | ||
magna.php | ||
makephar.php | ||
multiprocess_bot.php | ||
phar.php | ||
phartesting.php | ||
README.md | ||
secret_bot.php | ||
socket.php | ||
songs.php | ||
translator.php |
MadelineProto, a PHP MTProto telegram client
Do join the official channel, @MadelineProto and the support groups!
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!).
Getting started
<?php
if (!file_exists('madeline.php')) {
copy('https://phar.madelineproto.xyz/madeline.php', 'madeline.php');
}
include 'madeline.php';
// !!! This API id/API hash combination will not work !!!
// !!! You must get your own @ my.telegram.org !!!
$api_id = 0;
$api_hash = '';
$MadelineProto = new \danog\MadelineProto\API('session.madeline', ['app_info' => ['api_id' => $api_id, 'api_hash' => $api_hash]]);
$MadelineProto->start();
$MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => "Hi!\nThanks for creating MadelineProto! <3"]);
$MadelineProto->channels->joinChannel(['channel' => '@MadelineProto']);
try {
$MadelineProto->messages->importChatInvite(['hash' => 'https://t.me/joinchat/Bgrajz6K-aJKu0IpGsLpBg']);
} catch (\danog\MadelineProto\RPCErrorException $e) {
}
$MadelineProto->messages->sendMessage(['peer' => 'https://t.me/joinchat/Bgrajz6K-aJKu0IpGsLpBg', 'message' => 'Testing MadelineProto!']);
Run this code in a browser or in a console.
Tip: if you receive an error (or nothing), send us the error message and the Madeline.log
file that was created in the same directory (if running from a browser).
Documentation
- Creating a client
- Logging in
- Features
- Requirements
- Installation
- Handling updates
- Settings
- Getting info about the current user
- Exceptions
- Avoiding FLOOD_WAITs
- Logging
- Using methods
- Uploading and downloading files
- Getting info about chats
- Getting all chats
- Inline buttons
- Calls
- Secret chats
- Lua binding
- Using a proxy
- Contributing
Very complex and complete examples
You can find examples for nearly every MadelineProto function in
tests/testing.php
- examples for making/receiving calls, making secret chats, sending secret chat messages, videos, audios, voice recordings, gifs, stickers, photos, sending normal messages, videos, audios, voice recordings, gifs, stickers, photos.bot.php
- examples for sending normal messages, downloading any mediasecret_bot.php
- secret chat botmultiprocess_bot.php
- multithreaded botmagna.php
- examples for receiving callsuserbots/pipesbot.php
- examples for creating inline bots and using other inline bots via a userbotuserbots/MadelineProto_bot.php
- Multi-function botuserbots/pwrtelegram_debug_bot
- Multi-function bot