M
M
MasterEditor2017-07-08 20:07:07
Python
MasterEditor, 2017-07-08 20:07:07

How to send a GET request?

There was such a problem. I want to send a message using a get request. I am using the requests library. With methods that do not require access rights, everything works out fine. But when access rights are needed, nothing happens. I write scope=messages, but...

r = requests.get('https://api.vk.com/method/messages.send?user_id=1111&message=hello&scope=offline,messages&v=5.52&access_token=my_token')

Mistake:
{"error":{"error_code":15,"error_msg":"Access denied: no access to call this method","request_params":[{"key":"oauth","value":"1"},{"key":"method","value":"messages.send"},{"key":"user_id","value":"160400462"},{"key":"message","value":"hello"},{"key":"scope","value":"offline,messages"},{"key":"v","value":"5.52"},{"key":"expires_in","value":"86400"}]}}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
4
4X_Pro, 2017-07-08
@MasterEditor

scope needs to be written at the stage of obtaining a token, and not when sending a message. And the GET request itself goes fine.

M
Maxim Nevzorov, 2017-07-10
@fixator10

By the way, there is a ready-made library for requests to VK: https://pypi.python.org/pypi/vk

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question