W
W
WolfInChains2020-05-10 14:17:48
Python
WolfInChains, 2020-05-10 14:17:48

How to send a random photo from a group album with a community token?

Faced such a problem that the https://vk.com/dev/photos.getAll method does not work with the community token, can I somehow replace it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
WolfInChains, 2020-05-10
@WolfInChains

I solved the problem a little non-standard, a crutch so to speak, but if anyone needs it, then here's an example

if event.object.text == "Нами" or event.object.text == "нами":
                       photo_send = random.randint(31, 33)
                       vk.method("messages.send",
                                 {
                                     "chat_id": event.object.peer_id - 2000000000,
                                     "attachment": "photo-193643776_4572390" + f'{photo_send}',
                                     "random_id": random.randint(1, 2147483647)
                                 })

I opened the first photo of the album, copied the ID of the photo and erased the last 2 digits, made photo_send = random.randint(31, 33), where 31 and 33 are the last 2 digits of the ID of the first and last photo of the album, respectively, then simply added the resulting value to the ID and all.

Y
YariKartoshe4ka, 2020-05-10
@YariKartoshe4ka

No, use user access key

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question