MadelineProto/old_docs/API_docs_v25/methods/messages_search.md

92 lines
2.2 KiB
Markdown
Raw Normal View History

---
2017-01-19 23:02:27 +01:00
title: messages.search
description: messages.search parameters, return type and example
---
2017-01-19 23:02:27 +01:00
## Method: messages.search
[Back to methods index](index.md)
### Parameters:
| Name | Type | Required |
2017-08-20 11:05:56 +02:00
|----------|---------------|----------|
|peer|[InputPeer](../types/InputPeer.md) | Yes|
|q|[string](../types/string.md) | Yes|
|filter|[MessagesFilter](../types/MessagesFilter.md) | Yes|
|min\_date|[int](../types/int.md) | Yes|
|max\_date|[int](../types/int.md) | Yes|
|offset|[int](../types/int.md) | Yes|
|max\_id|[int](../types/int.md) | Yes|
|limit|[int](../types/int.md) | Yes|
### Return type: [messages\_Messages](../types/messages_Messages.md)
2017-08-28 12:44:50 +02:00
### Can bots use this method: **NO**
### Errors this method can return:
| Error | Description |
|----------|---------------|
2017-09-01 12:27:38 +02:00
|INPUT_CONSTRUCTOR_INVALID|The provided constructor is invalid|
2017-10-04 14:43:51 +02:00
|INPUT_USER_DEACTIVATED|The specified user was deleted|
2017-09-01 12:27:38 +02:00
|PEER_ID_INVALID|The provided peer id is invalid|
2017-09-25 12:26:30 +02:00
|SEARCH_QUERY_EMPTY|The search query is empty|
2017-10-04 14:43:51 +02:00
|USER_ID_INVALID|The provided user ID is invalid|
2017-09-01 12:27:38 +02:00
2017-08-28 12:44:50 +02:00
### Example:
```
$MadelineProto = new \danog\MadelineProto\API();
if (isset($number)) { // Login as a user
$sentCode = $MadelineProto->phone_login($number);
echo 'Enter the code you received: ';
$code = '';
for ($x = 0; $x < $sentCode['type']['length']; $x++) {
$code .= fgetc(STDIN);
}
$MadelineProto->complete_phone_login($code);
}
2017-07-23 16:33:46 +02:00
$messages_Messages = $MadelineProto->messages->search(['peer' => InputPeer, 'q' => 'string', 'filter' => MessagesFilter, 'min_date' => int, 'max_date' => int, 'offset' => int, 'max_id' => int, 'limit' => int, ]);
2017-02-13 04:33:06 +01:00
```
2017-07-24 01:32:29 +02:00
Or, if you're using the [PWRTelegram HTTP API](https://pwrtelegram.xyz):
2017-07-23 16:11:02 +02:00
2017-07-23 16:34:36 +02:00
2017-07-23 16:11:02 +02:00
### As a user:
POST/GET to `https://api.pwrtelegram.xyz/userTOKEN/messages.search`
Parameters:
peer - Json encoded InputPeer
2017-08-20 19:09:52 +02:00
2017-07-23 16:11:02 +02:00
q - Json encoded string
2017-08-20 19:09:52 +02:00
2017-07-23 16:11:02 +02:00
filter - Json encoded MessagesFilter
2017-08-20 19:09:52 +02:00
2017-07-23 16:11:02 +02:00
min_date - Json encoded int
2017-08-20 19:09:52 +02:00
2017-07-23 16:11:02 +02:00
max_date - Json encoded int
2017-08-20 19:09:52 +02:00
2017-07-23 16:11:02 +02:00
offset - Json encoded int
2017-08-20 19:09:52 +02:00
2017-07-23 16:11:02 +02:00
max_id - Json encoded int
2017-08-20 19:09:52 +02:00
2017-07-23 16:11:02 +02:00
limit - Json encoded int
2017-07-23 16:40:54 +02:00
2017-07-23 16:11:02 +02:00
2017-08-20 19:09:52 +02:00
Or, if you're into Lua:
```
2017-07-23 16:33:46 +02:00
messages_Messages = messages.search({peer=InputPeer, q='string', filter=MessagesFilter, min_date=int, max_date=int, offset=int, max_id=int, limit=int, })
```