1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-27 03:34:42 +01:00
Go to file
2018-03-22 19:50:57 +00:00
.vscode
docs Implemented web UI for my.telegram.org and bugfix 2018-03-22 19:50:57 +00:00
fuzz
lua Implement socket interface 2018-03-04 17:42:48 +01:00
old_docs Update docs 2018-03-20 22:18:19 +01:00
src Implemented web UI for my.telegram.org and bugfix 2018-03-22 19:50:57 +00:00
tests Documentation rework (#349) 2018-03-20 12:48:05 +01:00
userbots Implement socket interface 2018-03-04 17:42:48 +01:00
.babelrc
.env.calls
.env.example
.gitignore
.travis.yml
bot.php Documentation rework (#349) 2018-03-20 12:48:05 +01:00
build_docs_index.php Improve documentation 2018-03-21 12:09:14 +01:00
build_docs.php
CHANGELOG.md
CODE_OF_CONDUCT.md
composer.json Support altervista.org out of the box 2018-03-21 20:29:20 +00:00
CONTRIBUTING.md
index.php Implemented web UI for my.telegram.org and bugfix 2018-03-22 19:50:57 +00:00
input.raw
LICENSE
magna.php
makephar.php Implemented web UI for my.telegram.org and bugfix 2018-03-22 19:50:57 +00:00
multiprocess_bot.php Documentation rework (#349) 2018-03-20 12:48:05 +01:00
phar.php
phartesting.php Implement socket interface 2018-03-04 17:42:48 +01:00
README.md Now the default example works with bots, too 2018-03-21 12:24:38 +01:00
secret_bot.php Documentation rework (#349) 2018-03-20 12:48:05 +01:00
socket.php Update PrimeModule dependency and finish writing socket interface 2018-03-21 11:59:56 +01:00
songs.php
translator.php Documentation rework (#349) 2018-03-20 12:48:05 +01:00

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();    

$me = $MadelineProto->get_self();

\danog\MadelineProto\Logger::log($me);

if (!$me['bot']) {
    $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!']);
}
echo 'OK, done!'.PHP_EOL;

Try this code now! or 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 MadelineProto.log file that was created in the same directory (if running from a browser).

Documentation

Very complex and complete examples

You can find examples for nearly every MadelineProto function in