1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-30 07:58:58 +01:00
MadelineProto/testing.php

55 lines
2.2 KiB
PHP
Raw Normal View History

2016-08-09 22:28:50 +02:00
#!/usr/bin/env php
2016-06-23 23:51:08 +02:00
<?php
2016-11-16 15:18:35 +01:00
/*
Copyright 2016 Daniil Gentili
(https://daniil.it)
This file is part of MadelineProto.
MadelineProto is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
MadelineProto is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.
You should have received a copy of the GNU General Public License along with MadelineProto.
If not, see <http://www.gnu.org/licenses/>.
*/
2016-07-14 15:15:50 +02:00
2016-08-07 23:23:10 +02:00
require_once 'vendor/autoload.php';
2016-09-12 22:28:27 +02:00
$MadelineProto = new \danog\MadelineProto\API();
/*if (file_exists('number.php')) {
include_once 'number.php';
$sentCode = $MadelineProto->auth->sendCode(
[
'phone_number' => $number,
'sms_type' => 5,
'api_id' => $MadelineProto->API->settings['app_info']['api_id'],
'api_hash' => $MadelineProto->API->settings['app_info']['api_hash'],
'lang_code' => $MadelineProto->API->settings['app_info']['lang_code'],
]
);
var_dump($sentCode);
echo 'Enter the code you received: ';
$code = '';
for ($x = 0; $x < $sentCode['type']['length']; $x++) {
$code .= fgetc(STDIN);
}
$authorization = $MadelineProto->auth->signIn(
[
2016-11-23 21:04:51 +01:00
'phone_number' => $number,
'phone_code_hash' => $sentCode['phone_code_hash'],
2016-11-23 21:04:51 +01:00
'phone_code' => $code,
]
);
var_dump($authorization);
}*/
if (file_exists('token.php')) {
include_once 'token.php';
$botauthorization = $MadelineProto->auth->importBotAuthorization(
[
'bot_auth_token' => $token,
'api_id' => $MadelineProto->API->settings['app_info']['api_id'],
'api_hash' => $MadelineProto->API->settings['app_info']['api_hash'],
]
);
var_dump($botauthorization);
}
echo 'Size of MadelineProto instance is '.strlen(var_export($MadelineProto, true)).' bytes'.PHP_EOL;