Hello.
I am writing a bot to send entries from Telegram to VK I write in Python 3.5. To send a message I use this function:
def post(message): print(urllib.request.urlopen('https://api.vk.com/method/wall.post?from_group=1&owner_id='+owner_id+'&message='+message+'&access_token='+access_token+'&v=5.62').read()) In response, API VC sends me an error with a link to confirm actions:
{"error":{"error_code":17,"error_msg":"Validation required: please open redirect_uri in browser 246620520","request_params":[{"key":"oauth","value":"1"},{"key":"method","value":"wall.post"},{"key":"from_group","value":"1"},{"key":"owner_id","value":"(Группа)"},{"key":"message","value":"TestForBot"},{"key":"v","value":"5.62"}],"redirect_uri":"https:\\/\\/m.vk.com\\/login?act=security_check&api_hash=(Хэш)"}} Record after request to API did not appear. I tried to substitute crutches and did everything as follows:
def post(message): print('https://api.vk.com/method/wall.post?from_group=1&owner_id='+owner_id+'&message='+message+'&access_token='+access_token+'&v=5.62') validate=str(urllib.request.urlopen(Запрос к API).read()) print(validate) for i in range(len(validate)-16): if validate[i:i+16:]=='"redirect_uri":"': i+=16 validate_url='' while validate[i]!='"': if validate[i]!='\\': validate_url+=validate[i] i+=1 break requests.get(validate_url) That is, I made it so that after a request to the API, Python would open the link that had to be opened to confirm actions. Again nothing.
Tell me what am I doing wrong? If I send a request through the browser, then everything goes fine, without errors. Only through Python this happens.
I am using Python 3.5