import pyodnoklassniki
pyodnoklassniki.app_pub_key = 'app_pub_key '
pyodnoklassniki.app_secret_key = 'app_secret_key '
self.ok_api_Auth = pyodnoklassniki.OdnoklassnikiAPI(access_token='access_token', session_secret_key='session_secret_key')
photos = self.ok_api_Auth.photosV2.getUploadUrl(permissions='VALUABLE_ACCESS;LONG_ACCESS_TOKEN;GROUP_CONTENT;PHOTO_CONTENT',format = 'json',gid = 'group_id', count = 2)
#print (photos)
#print (photos['photo_ids'][0])
filename1 = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'repost') + '/1.jpg'
filename2 = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'repost') + '/2.jpg'
r = requests.post(str(photos['upload_url']), files={'1.jpg': open(filename1, 'rb'),'2.jpg': open(filename2, 'rb')}).json()
attachment = '{"media": [{' \
'"type": "photo", ' \
'"list": [' \
'{ "id": "' + str(r['photos'][str(photos['photo_ids'][0])]['token'])+ '" },' \
'{ "id": "' + str(r['photos'][str(photos['photo_ids'][1])]['token'])+ '" }' \
']},' \
'{"type": "link",' \
'"url": "' + str('http://ya.ru') + '"},' \
'{"type": "text",' \
'"text": "' + str('hello') + '"}' \
']}'
rgroups = self.ok_api_Auth.mediatopic.post(permissions='VALUABLE_ACCESS;LONG_ACCESS_TOKEN;GROUP_CONTENT;PHOTO_CONTENT',format = 'json', attachment=attachment, type='GROUP_THEME', gid='group_id')