How to delete messages in a conversation in the VC through VK API?

Which api method in the VC erases all messages of the conversation on behalf of admin chat for all users ? That is the old message to see nobody has
March 20th 20 at 11:31
1 answer
March 20th 20 at 11:33
there is no such method, but we do not despair and do:

with the help of messages.getHistory and execute receive all messages of the conversation at 5000 per request
code to execute will be something like this (better to minifirewall for speed):
var peer_id = 2000000001; // conversation ID
var results = [];
var i = 0; 
var offset = 0; 
while (i < 25) {
 results.push(API.messages.getHistory({peer_id: peer_id, count: 200, offset: offset}));
 i = i + 1;
 offset = offset + 200;
}
return results@.items;

the result will be an array of 25 arrays of message objects
with each request we need to increase the offset value to 5000

then iterate through these arrays of objects, and if the field from_id is equal to the ID of the admin conversation, then added the id field to any array of message_ids

when all message_ids are collected, simply send them to the method messages.delete parameter delete_for_all=1

send requests execute'ohms you want as long as the length of the array will not be zero

PS forgot to break off, the message can be cleared only within 24 hours after writing, alas...
This is not difficult and will make the finished code to my source code! I will be glad :)

$vk->request('messages.send', ['peer_id' => $peer_id, 'message' => ", 'attachment' => "photo-00000_00003"]);
$vk->request('messages.removeChatUser', ['chat_id' => $chat_id, 'member_id' => $chat_act->member_id]);
- Bette_Fer commented on March 20th 20 at 11:36

Find more questions by tags VKontakte