Answer the question
In order to leave comments, you need to log in
How to save an attachment in a message via vk_api?
Good afternoon! My bot can synthesize text from a text message into a voice message using the yandex speech kit.
Now I'm trying to do the opposite so that the bot responds to a voice message with text. Tell me, how can I save the received voice message?
$data = json_decode(file_get_contents('php://input'));
$attchType = $data->object->attachments[0]->type;
if ($data->type == 'message_new') {
if($attchType == 'audio_message') {
//Как скачать полученное сообщение?
}
}
Answer the question
In order to leave comments, you need to log in
Guys, thank you all! Found at random, this is how the code works, and saves the message.
if($attachType == 'audio_message') {
file_put_contents('audiomsg.ogg', file_get_contents($data->object->attachments[0]->audio_message->link_ogg));
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question