mirror of
https://github.com/danog/MadelineProtoDocs.git
synced 2024-11-26 20:35:03 +01:00
34 lines
943 B
Markdown
34 lines
943 B
Markdown
---
|
|
title: update2fa
|
|
description: Update 2FA password
|
|
redirect_from: /update_2fa.html
|
|
grand_parent: "Telegram RPC API"
|
|
parent: "Methods"
|
|
---
|
|
## Method: update2fa
|
|
|
|
The params array can contain password (current password), new_password, email (optional) and hint params.
|
|
|
|
### Parameters:
|
|
|
|
| Name | Type |
|
|
|----------|---------------|
|
|
|params|An array of parameters|
|
|
|
|
### Return type: [Bool](API_docs/types/Bool.html)
|
|
|
|
### Example ([now fully async!](https://docs.madelineproto.xyz/docs/ASYNC.html)):
|
|
|
|
|
|
```php
|
|
try {
|
|
$MadelineProto->update2fa(['password' => 'current password', 'new_password' => 'New password', 'email' => 'daniil@daniil.it', 'hint' => 'ponies']);
|
|
} catch (RPCErrorException $e) {
|
|
if (strpos($e->rpc, 'EMAIL_UNCONFIRMED_') !== false) {
|
|
$Bool = $MadelineProto->account->confirmPasswordEmail(['code' => $MadelineProto->readline('Enter your email code: ')]);
|
|
} else {
|
|
throw $e;
|
|
}
|
|
}
|
|
```
|