V
V
Vladimir Surkov2020-10-19 08:42:29
PHP
Vladimir Surkov, 2020-10-19 08:42:29

Vk api, how to send attachments from a message on behalf of a bot?

Good evening, Khabrovites), in general, I have been suffering with this problem for about a week, the fact is that I am making an anonymous chat bot VK, and the bot must accept messages and attachments from one user and send them on my behalf to another, I did resending messages without any problems, but I’m specifically stuck on attachments, I just can’t take attachments from one user’s message and send it to another, re-read the entire dock, wrote in tp, everywhere they advise uploading the attachment again, but how can I re-upload the attachment in VK which I don’t even have? I managed to resend attachments, but for some reason only to myself, it doesn’t work with other users, in general, help me out.

$message=$data->object->message->text;
    //Убираем префикс
$mess=mb_strtolower($message);
if(!empty($data->object->message->attachments[0])){
$get_id=$peer_Id;
$type=$data->object->message->attachments[0]->type;
$owner_id=$data->object->message->attachments[0]->$type->owner_id;
$photo_id=$data->object->message->attachments[0]->$type->id;
$access_key=$data->object->message->attachments[0]->$type->access_key;
$request_params = [
'message' => $mess,
'peer_id' => $get_id,
'attachment'=>"{$type}{$owner_id}_{$photo_id}_{$access_key}",
'random_id' => "0",
'access_token' => $token,
'v' => '5.103'
];
$get_params = http_build_query($request_params);
file_get_contents('https://api.vk.com/method/messages.send?'. $get_params);
echo 'ok'; 
break; 
};

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question