The vk.com/dev documentation says that метод messages.send принимает параметр attachment , but it is not clear how to pass this parameter to the messages.send? Thanks in advance for your reply.

  • one
    Just like you pass other parameters (user_id, message) - if you transfer a photo, for example, you pass photo (owner id) _ (picture id) to the attachment parameter - without brackets, if you want to transfer a picture from a computer, you must first load it into VK, then get its address, and then pass it to the attachment parameter. If you want to transfer several elements, then simply list them separated by commas - nicolaa
  • if (msg.body == "what are you doing?") msg.send ("Resting", attachment photo photo510970512_456239094); A bot is here for conversations, can you help with the correct wording of this command? - Karl Ziegler

1 answer 1

As I did, without the use of add. libraries

 $request_params = array( 'message' => $otwet,//Текст сообщения 'user_id' => $userId,//Кому отправляем 'access_token' => $token,//Токен 'attachment' => 'photo(id владельца)_(id картинки)',//Адрес фотографии, без скобочек, например photo-47801984_456243139. Минус после "photo" означает, что владелец группа, если фотография находиться у пользователя, то без минуса 'v' => '5.80',//Версия api ); file_get_contents('https://api.vk.com/method/messages.send?' . http_build_query($request_params));//Отправляем сообщение