Answer the question
In order to leave comments, you need to log in
Error vk_api.exceptions.ApiError: [100] One of the parameters specified was missing or invalid: peer_id not integer. How to solve it?
I recently started learning python. I decided to write a bot, as planned, it should send pictures from a computer. Here is the code:
def main():
for event in longpoll.listen():
if event.type == VkEventType.MESSAGE_NEW:
if event.to_me:
request = event.text.lower()
if request == '1':
a = vk.method("photos.getMessagesUploadServer")
b = requests.post(a['upload_url'], files={'photo': open('C:\data_for_bot\Bar.jpg', 'rb')}).json()
c = vk.method('photos.saveMessagesPhoto',{'photo': b['photo'], 'server': b['server'], 'hash': b['hash']})[0]
d = "photo{}_{}".format(c["owner_id"], c["id"])
vk.method("messages.send", {"peer_id": id, "message": "Bar", "attachment": d, "random_id": 0})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question