Answer the question
In order to leave comments, you need to log in
How to make it possible to send documents, stickers, gs?
Hello, I have an anonymous chat bot VK. The user writes to the group's messages to start, the interlocutor is searched for, and they start an anonymous dialogue through the bot. Now the bot is not able to send photos, voice, video, stickers. I would like to fix this situation, but I do not understand how.
Here is the code where the bot sends a message to the user:
if($user['id_interl'] != 'start' && $user['id_interl'] != 'null' && $payload != 'start' && $payload != 'stop'){
$interlocutor = R::findOne('test', 'user_id = ?', [$user['id_interl']]);
$vk->sendMessage($interlocutor['user_id'], '' . $message);
$vk->request('messages.markAsRead', ['message_ids' => $msg_id, 'peer_id' => $peer_id]);
}
Answer the question
In order to leave comments, you need to log in
Some documents are available without an access_token, they can simply be taken in the user's message, if he makes an attachment, then the json will contain the attachments parameter, which can contain photos, videos, stickers, etc. Simply put, you need to take this parameter and substitute it in the attachment parameter when sending a message, although then you will have to use the request () method, and not sendMessage ().
$attachment = "достать из json attachment";
$vk->request('messages.send',array('параметр 1' => '$value1,'параметр 2' => $value2, 'attachment' => $attachment))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question