I
I
ibr_982017-10-06 16:07:16
Python
ibr_98, 2017-10-06 16:07:16

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) #ПРИКРЕПЛЯЕМ САМО ФОТО И ОТПРАВЛЯЕМ

What can be wrong?
Thank you

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anatoly, 2017-10-06
@trofimovdev

You are only sending the id, although you also need to send the owner_id.
<owner_id>- ID of the owner of the media attachment (note that if the object is in the community, this parameter must be negative).
<media_id>— ID of the media attachment.
For example:

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question