MadelineProtoDocs/old_docs/API_docs_v23/methods/messages.searchGlobal.md

59 lines
1.9 KiB
Markdown
Raw Permalink Normal View History

2020-06-16 17:50:25 +02:00
---
title: messages.searchGlobal
description: Search for messages and peers globally
image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png
redirect_from: /API_docs/methods/messages_searchGlobal.html
---
# Method: messages.searchGlobal
[Back to methods index](index.md)
Search for messages and peers globally
### Parameters:
| Name | Type | Description | Required |
|----------|---------------|-------------|----------|
|q|[string](../types/string.md) | Query | Yes|
|offset\_date|[int](../types/int.md) | | Yes|
|offset\_peer|[Username, chat ID, Update, Message or InputPeer](../types/InputPeer.md) | [Offsets for pagination, for more info click here](https://core.telegram.org/api/offsets) | Optional|
|offset\_id|[int](../types/int.md) | [Offsets for pagination, for more info click here](https://core.telegram.org/api/offsets) | Yes|
|limit|[int](../types/int.md) | [Offsets for pagination, for more info click here](https://core.telegram.org/api/offsets) | Yes|
### Return type: [messages.Messages](../types/messages.Messages.md)
### 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();
$messages.Messages = $MadelineProto->messages->searchGlobal(['q' => 'string', 'offset_date' => int, 'offset_peer' => InputPeer, 'offset_id' => int, 'limit' => int, ]);
```
Or, if you're into Lua:
```lua
messages.Messages = messages.searchGlobal({q='string', offset_date=int, offset_peer=InputPeer, offset_id=int, limit=int, })
```
### Errors
| Code | Type | Description |
|------|----------|---------------|
2020-09-12 12:47:38 +02:00
|400|FOLDER_ID_INVALID|Invalid folder ID|
2020-06-16 17:50:25 +02:00
|400|SEARCH_QUERY_EMPTY|The search query is empty|