Answer the question
In order to leave comments, you need to log in
How to upload a photo to your Vkontakte wall using the Python VK API?
Good day to all. There is a code, but the photo is not fasting, only 'message' is fasting. Permission to photo in the application is.
import vk
import requests
import json
data=api.photos.getWallUploadServer(user_id=my_id)
data_upload_url=data['upload_url']
files={'photo': open('dobrota.jpg',"rb")}
r=requests.post(data_upload_url,files=files)
params={'server': r.json()['server'], 'photo': r.json()['photo'], 'hash': r.json()['hash']}
wallphoto=api.photos.saveWallPhoto(**params)
photoID = wallphoto[0]['id']
params={'attachments': 'photo' + 'my_id_' + str(photoID), 'message': 'Test', 'owner_id': my_id}
api.wall.post(**params)
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