MadelineProto/README.md

77 lines
3.9 KiB
Markdown
Raw Normal View History

2017-08-20 17:37:29 +02:00
# MadelineProto, a PHP MTProto telegram client
2015-03-11 16:42:20 +01:00
2017-08-28 11:38:44 +02:00
Do join the official channel, [@MadelineProto](https://t.me/MadelineProto)!
2017-08-20 18:04:54 +02:00
## What's this?
2017-08-20 18:04:54 +02:00
This library can be used to easily interact with Telegram without the bot API, just like the official apps.
2016-08-14 21:38:32 +02:00
## Installation
Simply download [madeline.php](https://phar.madelineproto.xyz/madeline.php).
## Getting started
2017-08-18 13:27:44 +02:00
```
<?php
2017-02-05 15:15:48 +01:00
include 'madeline.php';
2017-12-21 10:52:23 +01:00
// !!! This API id/API hash combination will not work !!!
// !!! You must get your own @ my.telegram.org !!!
$api_id = 0;
$api_hash = '';
2017-02-05 15:15:48 +01:00
2018-03-12 22:27:10 +01:00
$MadelineProto = new \danog\MadelineProto\API('session.madeline', ['app_info' => ['api_id' => $api_id, 'api_hash' => $api_hash]]);
2017-02-05 15:15:48 +01:00
$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): '));
}
2017-10-04 14:43:51 +02:00
```
## Simple example
2017-10-04 14:43:51 +02:00
```
$MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => "Hi!\nThanks for creating MadelineProto! <3"]);
$MadelineProto->channels->joinChannel(['channel' => '@MadelineProto']);
2017-10-04 14:43:51 +02:00
```
## Documentation
2017-10-04 14:43:51 +02:00
2018-03-12 22:17:45 +01:00
- [Features](https://docs.madelineproto.xyz/FULL_README.html#features)
- [Full method list](https://docs.madelineproto.xyz/API_docs/methods)
- [How to use these methods](https://docs.madelineproto.xyz/FULL_README.html#methods)
2018-03-12 22:17:45 +01:00
- [Clicking inline buttons](https://docs.madelineproto.xyz/FULL_README.html#inline-buttons)
- [Uploading and downloading files](https://docs.madelineproto.xyz/FULL_README.html#uploading-and-downloading-files)
- [Changing settings](https://docs.madelineproto.xyz/FULL_README.html#settings)
- [Update management (getting incoming messages)](https://docs.madelineproto.xyz/FULL_README.html#handling-updates)
- [Using a proxy](https://docs.madelineproto.xyz/FULL_README.html#using-a-proxy)
- [Calls](https://docs.madelineproto.xyz/FULL_README.html#calls)
- [Secret chats](https://docs.madelineproto.xyz/FULL_README.html#secret-chats)
- [Storing sessions](https://docs.madelineproto.xyz/FULL_README.html#storing-sessions)
- [Exceptions](https://docs.madelineproto.xyz/FULL_README.html#exceptions)
- [Lua binding](https://docs.madelineproto.xyz/FULL_README.html#lua-binding)
2017-10-04 14:43:51 +02:00
2017-08-18 13:27:44 +02:00
## Very complex and complete examples
2017-08-18 13:27:44 +02:00
You can find examples for nearly every MadelineProto function in
* [`tests/testing.php`](https://github.com/danog/MadelineProto/blob/master/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`](https://github.com/danog/MadelineProto/blob/master/bot.php) - examples for sending normal messages, downloading any media
* [`secret_bot.php`](https://github.com/danog/MadelineProto/blob/master/secret_bot.php) - secret chat bot
* [`multiprocess_bot.php`](https://github.com/danog/MadelineProto/blob/master/multiprocess_bot.php) - multithreaded bot
2017-08-18 13:27:44 +02:00
* [`magna.php`](https://github.com/danog/MadelineProto/blob/master/magna.php) - examples for receiving calls
* [`userbots/pipesbot.php`](https://github.com/danog/MadelineProto/blob/master/userbots/pipesbot.php) - examples for creating inline bots and using other inline bots via a userbot
* [`userbots/MadelineProto_bot.php`](https://github.com/danog/MadelineProto/blob/master/userbots/MadelineProto_bot.php) - Multi-function bot
* [`userbots/pwrtelegram_debug_bot`](https://github.com/danog/MadelineProto/blob/master/userbots/pwrtelegram_debug_bot.php) - Multi-function bot
2016-10-07 00:36:18 +02:00