I
I
Ivan Wagner2020-01-14 13:45:53
API
Ivan Wagner, 2020-01-14 13:45:53

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]);
}

But from the
API TYK
documentation I can’t understand what, how and where ..

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
TostPOST, 2020-01-14
@manavar_g

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))

A
Andrey, 2020-01-14
@anerev

Photos, videos, voice messages are sent via access_token which comes in response with a user message containing photos, videos, etc., each file has its own access token

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question