D
D
Denny_Colt2018-11-21 07:14:02
Python
Denny_Colt, 2018-11-21 07:14:02

What is the correct way to send "wall post" VK API in Python 3?

I'm trying to use the wall post method from a Python 3 script. Everything works well, but only with English text, when I try to use Cyrillic, it sends a maximum of 700 characters. The same thing happens on the method page (Example request). What could be the problem? Technical support answered: "Most likely, the fact is that you are making a GET request", but here you can see that POST .. Who understands this?

# -*- coding: utf-8 -*-
import requests
import json

token = "Токен"
application_id = 5182500
group_id = 172392334
owner_id_group = -172392334
foo = 'Русский текст 2000 символов'

requests.post('https://api.vk.com/method/wall.post', params={'access_token': token,
                                                                    'owner_id': owner_id_group,
                                                                    'from_group': 1,
                                                                    'message': foo,
                                                                    'signed': 0,
                                                                   'v':"5.52"}).json() #ругается ошибкой JSONDecodeError
                                   # или прочими. работает только с ангийским текстом

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladlen Hellsite, 2018-11-21
@Denny_Colt

Well, that's how you send query data to Query, not Body.

requests.post('https://api.vk.com/method/wall.post', data={'access_token': token,
                                                                    'owner_id': owner_id_group,
                                                                    'from_group': 1,
                                                                    'message': foo,
                                                                    'signed': 0,
                                                                   'v':"5.52"}).json()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question