V
V
vante_scribaxxi2018-03-23 20:58:44
Python
vante_scribaxxi, 2018-03-23 20:58:44

Python requests, why vk api issues Access dinied on photos.getWallUploadServer?

Error code

{"error":{"error_code":15,"error_msg":"Access denied: no access to call this method","request_params":[{"key":"oauth","value":"1"},{"key":"method","value":"photos.getWallUploadServer"},{"key":"group_id","value":"60116316"},{"key":"v","value":"5.73"}]}}

Script code
img = {'photo': open(photos[0], 'rb')}

url = 'https://api.vk.com/method/photos.getWallUploadServer?group_id='+ gid +'&v=5.73&access_token=тут_токен'
response = requests.get(url)
result = json.loads(response.text)
print(result)
upload_url = result['response']['upload_url']

response = requests.post(upload_url, files=img)
result = json.loads(response.text)

method_url = 'https://api.vk.com/method/photos.saveWallPhoto?'
data = dict(access_token=token, group_id=gid, photo=result['photo'], hash=result['hash'], server=result['server'], v="5.73")
response = requests.post(method_url, data)
result = json.loads(response.text)['response'][0]['id']

method_url = 'https://api.vk.com/method/wall.post?'
data = dict(access_token=token, owner_id='-' + gid, attachments=result, message='', v="5.73")
response = requests.post(method_url, data)
result = json.loads(response.text)

scope=messages,wall,photos,groups,friends
app_id=2890984

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