Answer the question
In order to leave comments, you need to log in
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
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)
Answer the question
In order to leave comments, you need to log in
>photos.getMessagesUploadServer
Returns the server address for uploading a photo to a private message
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question