2018-04-01 13:19:25 +02:00
|
|
|
---
|
|
|
|
title: auth.sendCode
|
2020-09-12 12:47:38 +02:00
|
|
|
description: Send the verification code for login
|
2018-04-04 19:52:48 +02:00
|
|
|
image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png
|
2019-12-27 18:46:25 +01:00
|
|
|
redirect_from: /API_docs/methods/auth_sendCode.html
|
2018-04-01 13:19:25 +02:00
|
|
|
---
|
2020-09-12 12:47:38 +02:00
|
|
|
# Method: auth.sendCode
|
2018-04-01 13:19:25 +02:00
|
|
|
[Back to methods index](index.md)
|
|
|
|
|
|
|
|
|
2020-09-12 12:47:38 +02:00
|
|
|
|
|
|
|
Send the verification code for login
|
2018-04-01 13:19:25 +02:00
|
|
|
|
2019-09-02 17:41:28 +02:00
|
|
|
### Parameters:
|
2018-04-01 13:19:25 +02:00
|
|
|
|
2019-09-02 17:41:28 +02:00
|
|
|
| Name | Type | Description | Required |
|
|
|
|
|----------|---------------|-------------|----------|
|
2020-09-12 12:47:38 +02:00
|
|
|
|phone\_number|[string](../types/string.md) | Phone number in international format | Yes|
|
|
|
|
|api\_id|[int](../types/int.md) | Application identifier (see [App configuration](https://core.telegram.org/myapp)) | Yes|
|
|
|
|
|api\_hash|[string](../types/string.md) | Application secret hash (see [App configuration](https://core.telegram.org/myapp)) | Yes|
|
|
|
|
|settings|[CodeSettings](../types/CodeSettings.md) | Settings for the code type to send | Yes|
|
2019-09-02 17:41:28 +02:00
|
|
|
|
|
|
|
|
2019-12-27 18:25:37 +01:00
|
|
|
### Return type: [auth.SentCode](../types/auth.SentCode.md)
|
2019-09-02 17:41:28 +02:00
|
|
|
|
|
|
|
### Can bots use this method: **NO**
|
|
|
|
|
|
|
|
|
|
|
|
### MadelineProto Example ([now async for huge speed and parallelism!](https://docs.madelineproto.xyz/docs/ASYNC.html)):
|
|
|
|
|
|
|
|
|
|
|
|
```php
|
|
|
|
if (!file_exists('madeline.php')) {
|
|
|
|
copy('https://phar.madelineproto.xyz/madeline.php', 'madeline.php');
|
|
|
|
}
|
|
|
|
include 'madeline.php';
|
|
|
|
|
|
|
|
$MadelineProto = new \danog\MadelineProto\API('session.madeline');
|
|
|
|
$MadelineProto->start();
|
|
|
|
|
2020-09-12 12:47:38 +02:00
|
|
|
$auth.SentCode = $MadelineProto->auth->sendCode(['phone_number' => 'string', 'api_id' => int, 'api_hash' => 'string', 'settings' => CodeSettings, ]);
|
2019-09-02 17:41:28 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
Or, if you're into Lua:
|
|
|
|
|
|
|
|
```lua
|
2020-09-12 12:47:38 +02:00
|
|
|
auth.SentCode = auth.sendCode({phone_number='string', api_id=int, api_hash='string', settings=CodeSettings, })
|
2019-09-02 17:41:28 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
### Errors
|
|
|
|
|
|
|
|
| Code | Type | Description |
|
|
|
|
|------|----------|---------------|
|
|
|
|
|400|API_ID_INVALID|API ID invalid|
|
|
|
|
|400|API_ID_PUBLISHED_FLOOD|This API id was published somewhere, you can't use it now|
|
|
|
|
|400|INPUT_REQUEST_TOO_LONG|The request is too big|
|
|
|
|
|400|PHONE_NUMBER_APP_SIGNUP_FORBIDDEN|You can't sign up using this app|
|
|
|
|
|400|PHONE_NUMBER_BANNED|The provided phone number is banned from telegram|
|
|
|
|
|400|PHONE_NUMBER_FLOOD|You asked for the code too many times.|
|
|
|
|
|400|PHONE_NUMBER_INVALID|The phone number is invalid|
|
|
|
|
|400|PHONE_PASSWORD_PROTECTED|This phone is password protected|
|
|
|
|
|400|SMS_CODE_CREATE_FAILED|An error occurred while creating the SMS code|
|
2020-09-12 12:47:38 +02:00
|
|
|
|406|AUTH_KEY_DUPLICATED|An auth key with the same ID was already generated|
|
2019-09-02 17:41:28 +02:00
|
|
|
|406|PHONE_NUMBER_INVALID|The phone number is invalid|
|
|
|
|
|406|PHONE_PASSWORD_FLOOD|You have tried logging in too many times|
|
2020-09-12 12:47:38 +02:00
|
|
|
|401|AUTH_KEY_PERM_EMPTY|The temporary auth key must be binded to the permanent auth key to use these methods.|
|
2018-04-01 13:19:25 +02:00
|
|
|
|
|
|
|
|