mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-26 23:34:44 +01:00
4.0 KiB
4.0 KiB
MadelineProto, a PHP MTProto telegram client
Do join the official channel, @MadelineProto!
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!).
Installation
Simply download madeline.php.
Getting started
<?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->phone_login(readline('Enter your phone number: '));
$authorization = $MadelineProto->complete_phone_login(readline('Enter the phone code: '));
if ($authorization['_'] === 'account.password') {
$authorization = $MadelineProto->complete_2fa_login(readline('Please enter your password (hint '.$authorization['hint'].'): '));
}
if ($authorization['_'] === 'account.needSignup') {
$authorization = $MadelineProto->complete_signup(readline('Please enter your first name: '), readline('Please enter your last name (can be empty): '));
}
Simple example
$MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => "Hi!\nThanks for creating MadelineProto! <3"]);
$MadelineProto->channels->joinChannel(['channel' => '@MadelineProto']);
Documentation
- Features
- Full method list
- How to use these methods
- Clicking inline buttons
- Uploading and downloading files
- Changing settings
- Update management (getting incoming messages)
- Using a proxy
- Calls
- Secret chats
- Storing sessions
- Exceptions
- Lua binding
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