How to attach pictures to vk_api in Python in a message?

  • 0
    Hello. I do not know how to send pictures, because the documentation is not written to me clearly. Please tell me the code.
    Python Anonymous, Apr 3, 2020

  • 2 Answers
  • 0
    The attachment parameter must be used. The attachment photo will look something like this: photo {ownerid} _ {photoid}.

    vk.method("messages.send", {"peer_id": event.object.peer_id, "message": "", 
    "attachment": "photo123_232,photo-1_1223"}) #отправка сообщения без текста с заранее выбранной картинкой
    Claire Matthews

  • 0
    In this case, the photo must be in the album of the group through which it is sent or transmitted with access token-om

    vk_session = vk_api.VkApi(

    vk = vk_session.get_api()

    vk.messages.send(random_id=time.time(), peer_id=peer_id, attachment=photo123_232)
    Landen Sampson

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!