Y
Y
yamudaqq2020-02-05 19:38:28
Python
yamudaqq, 2020-02-05 19:38:28

How do I upload a photo to a community private message?

There is a direct link to the photo.
How can I send a photo to a community member in private messages?

import vk
userid=какой вам удобно
photourl=('https://cdn2.thecatapi.com/images/MTQ5NzQ2MA.jpg')
def uploadphoto (userid, photourl):
    uploadserver=api.photos.getMessagesUploadServer()
    uplurl=uploadserver['upload_url']


And I kind of get stuck on it. There are only ways to download images directly from the computer's memory all over the Internet, and I need it directly to avoid delays.
In fact, I only need a JSON object with the server, photo, hash fields, which I will receive by transferring the file to the uplurl address obtained in the previous paragraph by generating a POST request with the photo field. But don't know how to do it.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question