2019-06-24 15:45:02 +02:00
|
|
|
---
|
|
|
|
title: contacts.addContact
|
2019-12-27 17:48:04 +01:00
|
|
|
description: Add an existing telegram user as contact
|
2019-06-24 15:45:02 +02:00
|
|
|
image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png
|
|
|
|
---
|
|
|
|
# Method: contacts.addContact
|
|
|
|
[Back to methods index](index.md)
|
|
|
|
|
|
|
|
|
2019-12-27 17:48:04 +01:00
|
|
|
Add an existing telegram user as contact
|
2019-06-24 15:45:02 +02:00
|
|
|
|
|
|
|
### Parameters:
|
|
|
|
|
|
|
|
| Name | Type | Description | Required |
|
|
|
|
|----------|---------------|-------------|----------|
|
2019-12-27 17:48:04 +01:00
|
|
|
|add\_phone\_privacy\_exception|[Bool](../types/Bool.md) | Allow the other user to see our phone number? | Optional|
|
|
|
|
|id|[Username, chat ID, Update, Message or InputUser](../types/InputUser.md) | Telegram ID of the other user | Optional|
|
2019-06-24 15:45:02 +02:00
|
|
|
|first\_name|[string](../types/string.md) | First name | Yes|
|
|
|
|
|last\_name|[string](../types/string.md) | Last name | Yes|
|
2019-12-27 17:48:04 +01:00
|
|
|
|phone|[string](../types/string.md) | User's phone number | Yes|
|
2019-06-24 15:45:02 +02:00
|
|
|
|
|
|
|
|
|
|
|
### Return type: [Updates](../types/Updates.md)
|
|
|
|
|
2019-06-30 15:12:21 +02:00
|
|
|
### Can bots use this method: **NO**
|
2019-06-24 15:45:02 +02:00
|
|
|
|
|
|
|
|
|
|
|
### 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();
|
|
|
|
|
|
|
|
$Updates = $MadelineProto->contacts->addContact(['add_phone_privacy_exception' => Bool, 'id' => InputUser, 'first_name' => 'string', 'last_name' => 'string', 'phone' => 'string', ]);
|
|
|
|
```
|
|
|
|
|
|
|
|
Or, if you're into Lua:
|
|
|
|
|
|
|
|
```lua
|
|
|
|
Updates = contacts.addContact({add_phone_privacy_exception=Bool, id=InputUser, first_name='string', last_name='string', phone='string', })
|
|
|
|
```
|
|
|
|
|
2019-09-02 17:41:28 +02:00
|
|
|
### Errors
|
2019-08-15 20:25:16 +02:00
|
|
|
|
2019-09-02 17:41:28 +02:00
|
|
|
| Code | Type | Description |
|
|
|
|
|------|----------|---------------|
|
|
|
|
|400|CONTACT_ID_INVALID|The provided contact ID is invalid|
|
2019-10-29 19:02:30 +01:00
|
|
|
|400|CONTACT_NAME_EMPTY|Contact name empty|
|
2019-08-15 20:25:16 +02:00
|
|
|
|
|
|
|
|