mirror of
https://github.com/danog/MadelineProto.git
synced 2024-12-02 12:17:47 +01:00
Dot env (#38)
* * Changes for use .env file and not a php with sensible data * * Changes for use .env file and not a php with sensible data * * Changes for use .env file and not a php with sensible data * * Changes for use .env file and not a php with sensible data * Changes for use .env files * Moving $settings to .env file * Update testing.php syntax * Update testing.php
This commit is contained in:
parent
64afc0290b
commit
bc97fff5e7
@ -1 +1,2 @@
|
|||||||
NUMBER=+5521999596772
|
MTPROTO_NUMBER=+123456789
|
||||||
|
MTPROTO_SETTINGS=[]
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -72,7 +72,6 @@ target/
|
|||||||
*.swp
|
*.swp
|
||||||
vendor
|
vendor
|
||||||
*bak
|
*bak
|
||||||
number.php
|
|
||||||
token.php
|
token.php
|
||||||
*~uploading*
|
*~uploading*
|
||||||
session.mad
|
session.mad
|
||||||
|
11
testing.php
11
testing.php
@ -12,25 +12,28 @@ If not, see <http://www.gnu.org/licenses/>.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
require_once 'vendor/autoload.php';
|
require_once 'vendor/autoload.php';
|
||||||
$settings = [];
|
|
||||||
if (file_exists('web_data.php')) {
|
if (file_exists('web_data.php')) {
|
||||||
require_once 'web_data.php';
|
require_once 'web_data.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
$MadelineProto = \danog\MadelineProto\Serialization::deserialize('session.madeline');
|
$MadelineProto = \danog\MadelineProto\Serialization::deserialize('session.madeline');
|
||||||
|
|
||||||
if (file_exists('number.php') && $MadelineProto === false) {
|
if (file_exists('.env')) {
|
||||||
$dotenv = new Dotenv\Dotenv(__DIR__);
|
$dotenv = new Dotenv\Dotenv(__DIR__);
|
||||||
$dotenv->load();
|
$dotenv->load();
|
||||||
|
}
|
||||||
|
$settings = json_decode(getenv('MTPROTO_SETTINGS'), true) ?: [];
|
||||||
|
|
||||||
|
if ($MadelineProto === false) {
|
||||||
$MadelineProto = new \danog\MadelineProto\API($settings);
|
$MadelineProto = new \danog\MadelineProto\API($settings);
|
||||||
|
|
||||||
$checkedPhone = $MadelineProto->auth->checkPhone(// auth.checkPhone becomes auth->checkPhone
|
$checkedPhone = $MadelineProto->auth->checkPhone(// auth.checkPhone becomes auth->checkPhone
|
||||||
[
|
[
|
||||||
'phone_number' => getenv('NUMBER'),
|
'phone_number' => getenv('MTPROTO_NUMBER'),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
\danog\MadelineProto\Logger::log($checkedPhone);
|
\danog\MadelineProto\Logger::log($checkedPhone);
|
||||||
$sentCode = $MadelineProto->phone_login(getenv('NUMBER'));
|
$sentCode = $MadelineProto->phone_login(getenv('MTPROTO_NUMBER'));
|
||||||
\danog\MadelineProto\Logger::log($sentCode);
|
\danog\MadelineProto\Logger::log($sentCode);
|
||||||
echo 'Enter the code you received: ';
|
echo 'Enter the code you received: ';
|
||||||
$code = fgets(STDIN, (isset($sentCode['type']['length']) ? $sentCode['type']['length'] : 5) + 1);
|
$code = fgets(STDIN, (isset($sentCode['type']['length']) ? $sentCode['type']['length'] : 5) + 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user