Answer the question
In order to leave comments, you need to log in
How to use attachments?
Hello!
Please tell me how to use the attribute attachments
in, vk api?
for example, I want to post this photo " https://pp.userapi.com/c836328/v836328573/61cb1/9O... " to my group, what do I need to do for this?
vk.wall.post(owner_id=group, from_group=1, attachments=?)
Answer the question
In order to leave comments, you need to log in
According to the link, no way. You must first download the image, and then upload it to the VK server.
It is possible not to re-upload if we have an id and an owner id, optionally an access_key to attach a non-shared attachment.
Everything is well described in the documentation:
список объектов, приложенных к записи и разделённых символом ",". Поле attachments представляется в формате: <type><owner_id>_<media_id>,<type><owner_id>_<media_id> Например: photo100172_166443618,photo-1_265827614
Using vk_api module (upload to group):
upload = vk_api.VkUpload(vk_session)
foto = upload.photo('PATH/foto.jpg', album_id="id_альбома", group_id="id_группы")
vk_photo_url = 'https://vk.com/photo{}_{}'.format(foto[0]['owner_id'], foto[0]['id'])
photo.append(vk_photo_url.replace('https://vk.com/', ''))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question