Answer the question
In order to leave comments, you need to log in
How to send a photo from one user to another in VK?
Hello, the question arose how to send a photo from one user to another.
This is what is passed in <<class 'vk_api.bot_longpoll.VkBotMessageEvent'>
to 'attachments'
'attachments': [{'type': 'photo', 'photo': {'access_key': '56e2d90bbb91ae012b', 'owner_id': 106XXXXXX, 'album_id': -3, 'id': 456242359, 'text': '', 'sizes': [{'height': 75, 'type': 's', 'url': 'https://pp.userapi.com/c852028/v852028876/e7028/1Frca866Q5Q.jpg', 'width': 75}, {'height': 130, 'type': 'm', 'url': 'https://pp.userapi.com/c852028/v852028876/e7029/wuKuedtFiQA.jpg', 'width': 130}, {'height': 604, 'type': 'x', 'url': 'https://pp.userapi.com/c852028/v852028876/e702a/mRla0liqWRg.jpg', 'width': 604}, {'height': 760, 'type': 'y', 'url': 'https://pp.userapi.com/c852028/v852028876/e702b/6YMoHN3_XbY.jpg', 'width': 760}, {'height': 130, 'type': 'o', 'url': 'https://pp.userapi.com/c852028/v852028876/e702c/fHu8F1o6UYs.jpg', 'width': 130}, {'height': 200, 'type': 'p', 'url': 'https://pp.userapi.com/c852028/v852028876/e702d/H5MtTsR9qB8.jpg', 'width': 200}, {'height': 320, 'type': 'q', 'url': 'https://pp.userapi.com/c852028/v852028876/e702e/unE2tVTbrXY.jpg', 'width': 320}, {'height': 510, 'type': 'r', 'url': 'https://pp.userapi.com/c852028/v852028876/e702f/hR3tuUXqzOA.jpg', 'width': 510}], 'date': 1553413111}}], >
'photo106XXXXXX_456242359_56e2d90bbb91ae012b'
atta = event.obj.attachments
buf = []
for element in atta:
if element['type'] == 'photo':
try:
buf.append('photo' + str(element['photo']['owner_id']) + '_' + str(
element['photo']['id']) + '_' + str(element['photo']['access_key']))
print('в фото есть ключ')
except:
print('в фото нет ключа')
buf.append('photo' + str(element['photo']['owner_id']) + '_' + str(element['photo']['id']))
<<class 'vk_api.bot_longpoll.VkBotMessageEvent'>
happens, the event does not come. Answer the question
In order to leave comments, you need to log in
The problem was an invalid access key. which is transferred to<<class 'vk_api.bot_longpoll.VkBotMessageEvent'>.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question