W
W
WolfInChains2020-07-07 20:55:03
Python
WolfInChains, 2020-07-07 20:55:03

Why is an empty comment being sent without a photo?

Uploading an image like this

def get_photo():
    upload = requests.post(vk.photos.getMessagesUploadServer()['upload_url'], files={'photo': open(os.path.join(DIR, random.choice(os.listdir(DIR))), 'rb')}).json()
    get = vk.photos.saveMessagesPhoto(photo=upload['photo'], server=upload['server'], hash=upload['hash'])[0]
    photo = "photo{}_{}".format(get["owner_id"], get["id"])
    print(photo)
    return photo

Send like this
def create_comment_photo(atch):
    vk.wall.createComment(owner_id=int(data[0]), post_id=int(data[1]), attachments=atch)

    if funct == 2:
        for comments in range(msg_count):
            create_comment_photo(get_photo())
            msg_num += 1
            print(f'Комментарий {msg_num} отправлен')
            time.sleep(2.2)

Everything is fine in the logs
5f04b6f21b34d610919141.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2020-07-07
@WolfInChains

>photos.getMessagesUploadServer

Returns the server address for uploading a photo to a private message

You are not sending a private message.
I need one of them, I won’t say for sure, rather the second
https://vk.com/dev/photos.getWallUploadServer
https://vk.com/dev/photos.getUploadServer

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question