E
E
Evgeny Lavrov2020-01-08 09:58:15
Python
Evgeny Lavrov, 2020-01-08 09:58:15

How to send a VK message on your own behalf (not from a group)?

I can’t find in Google how to send a message on my own behalf, everywhere only on behalf of the group

import vk_api
import json

# Настройки
login = "логин"
password = "пароль"

# Вход в вк
vk_session = vk_api.VkApi(login, password)
vk_session.auth()
vk = vk_session.get_api()

# Отправка сообщений
user_id = 546345252
msg = "Привет"

vk.messages.send(user_id=user_id, message=msg, random_id = 0)

I get an error
vk_api.exceptions.ApiError: [15] Access denied: no access to call this method

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sergeyfilippov4, 2020-01-14
@lavrov2002

Getting a token via Kate Mobile on vkhost.github.io

import vk_api
token = ""
user_id = 1 # type: int
vk = vk_api.VkApi(token=token).get_api()
vk.messages.send(
    user_id=user_id
    message=0
    random_id=0
)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question