Есть код:
import requests
import json
album_id= 262813577
group_id= 181583449
token='720c6caffa48c57e4730e4c41dd3be9099c4765965a185e15cf7c2de2cdbd5c17c751e5535a60b56b4747'
def get_upload_server():
r = requests.get('https://api.vk.com/method/photos.getUploadServer', params={'access_token':token,
'album_id': album_id,
'group_id':group_id
}).json()
print(r)
return r['response']['upload_url']
def main():
upload_url=get_upload_server()
file = {'fiel':open('1.jpg',rb)}
ur = requests.post(upload_url, files=file).json()
result = requsets.get('https://api.vk.com/method/photos.save', params={'access_token':token,
'album_id': ur['aid'],
'group_id':group_id,
'server':ul['server'],
'photos_list':ul['photos_list'],
'hash':ur['hash']}).json()
if __name__=='__main__':
main()
Кидает ошибку:
Traceback (most recent call last):
File "C:\Users\User\Desktop\bot_school\bot_my\test.py", line 25, in <module>
main()
File "C:\Users\User\Desktop\bot_school\bot_my\test.py", line 14, in main
upload_url=get_upload_server()
File "C:\Users\User\Desktop\bot_school\bot_my\test.py", line 12, in get_upload_server
return r['response']['upload_url']
KeyError: 'response'
Вывел r :
{'error': {'error_code': 5, 'error_msg': 'User authorization failed: method is unavailable with group auth.', 'request_params': [{'key': 'oauth', 'value': '1'}, {'key': 'method', 'value': 'photos.getUploadServer'}, {'key': 'album_id', 'value': '262813577'}, {'key': 'group_id', 'value': '181583449'}]}}
Токен рабочий
ВОПРОС: Как получить разрешение для группы?
P.s: Раньше этот же код работал.