Answer the question
In order to leave comments, you need to log in
Why is the image not attached?
Hello! There was such a problem, after executing the code below, only the word "hello" is sent, but the photo is not sent, why? I have attached it..
import vk
import requests
session = vk.AuthSession(app_id="***", user_login="***",
user_password="***", scope="messages, status, wall, friends, photos")
vk = vk.API(session) #АВТОРИЗОВЫВАЕМСЯ
getMes = vk.photos.getMessagesUploadServer(peer_id=211748612) #БЕРЕМ ЮРЛ
getUpload = getMes['upload_url']
file = {'file': open('newpng.png', 'rb')} #БЕРЕМ ФОТО
ur = requests.post(getUpload, files=file).json() #загружаем на сервер
result = vk.photos.saveMessagesPhoto(photo=ur['photo'], server=ur['server'], hash=ur['hash']) #СОХРАНЯЕМ
vk.messages.send(user_id=211748612, message='привет', attachments=result[0]['id'], v=5.38) #ПРИКРЕПЛЯЕМ САМО ФОТО И ОТПРАВЛЯЕМ
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question