P
P
prostiim2020-08-27 20:08:33
Python
prostiim, 2020-08-27 20:08:33

What is the problem with my request?

Hello ,

I'm making the following request
requests.get(' https://api.vk.com/method/messages.send?chat_id=18... , you can guess&access_token=14923a2c4593d10f2d4e80bafdd25416361addb24f7ee21783fc7ce47adeade5c4b07&v=5.122')
But for some reason I don't get anything. What is the problem?
Language - python

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
Guerro69, 2020-08-27
@prostiim

-_-, most api requests for VK messages are POST requests.
Also advice, it is better to pass all your parameters to the dictionary and then to the params argument

import requests
s = requests.Session()
params = {
    'chat_id': 18,
    'message': 'привет'
    'access_token': 'token',
    'random_id': 0
    'v': 5
}
s.post('https://api.vk.com/method/messages.send', params=params)
# и да хоть бы не палил свой токен

E
enwr, 2020-08-27
@enwr

try this:
import requests
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36',
'Content-Type ':'application/x-www-form-urlencoded',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Encoding ':'identity',
'accept-language':'ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3',
'Connection':'keep-alive',
'DNT ':'1',
'CF-Request-ID':'0475e3fb8e00007b237da5e200000001',
'requests':''
}
r = requests.session()
r.get(' https://api.vk.com/ ', headers = headers)
probably VK can not get the necessary data

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question