Saving photos from custom VkLongPoll Python attachments
Hello! I'm trying to make a bot, I need to get an image from the user, and save it in a file. At the moment I can't get a link to the image and this code:
vk_session = vk_api.VkApi(token='токен сообщества')
Lslongpoll = VkLongPoll(vk_session)
Lsvk = vk_session.get_api()
for event in Lslongpoll.listen():
if event.type == VkEventType.MESSAGE_NEW and event.to_me and event.text:
atchs = event.attachments
if atchs:
if atchs['attach1_type'] == 'photo':
photo_id = event.attachments['attach1']
photo_info = Lsvk.photos.get_by_id(photos=photo_id)
photo_urls = {size['type']: size['url'] for size in photo_info['sizes']}
print(photo_urls)
Crashes with an error:
vk_api.exceptions.ApiError: [27] Group authorization failed: method is unavailable with group auth.
Question - how to log in to the bot correctly, and how to write the photo to a file in the future?
0