F
F
fandorin_official2019-08-09 20:48:24
Python
fandorin_official, 2019-08-09 20:48:24

How to "pack" a request to the VK API?

There is some request to the VK API.
The URL is:
https://vk.com/dev/wall.post?params[owner_id]=-1&p...
How to correctly "pack" such a url so that the code is readable and the request parameters are easily changed.
I tried something like:

url = 'https://vk.com/dev/wall.post'
params = {
    'owner_id': '-1',
    'friends_only': '0',
    'from_group': '1',
    'message': 'Test',
    'signed': '0',
    'mark_as_ads': '0',
    'close_comments': '0',
    'mute_notifications': '0',
    'v': '5.101'
}
r = requests.post('https://vk.com/dev/wall.post', params=params).url

But in this case, the url is like this:
https://vk.com/dev/wall.post?owner_id=-166958401&f...
How to implement it correctly?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
Hiccup Heddok, 2019-08-09
@Hiccup

To work with the VK API, there is the vk_api library. Or are you reinventing the wheel?

E
Evgeny Mikhailovsky, 2019-08-10
@feelan

Use the vk_api library and enter the token

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question