Answer the question
In order to leave comments, you need to log in
Why is VK API error in Python?
I wanted to make a bot for a VK conversation from a personal page, the code is below
import vk_api
import requests
session = requests.Session()
login, password = 'my login', 'my passwd'
vk_session = vk_api.VkApi(login, password)
try:
vk_session.auth(token_only=True)
except vk_api.AuthError as error_msg:
print(error_msg)
from vk_api.longpoll import VkLongPoll, VkEventType
longpoll = VkLongPoll(vk_session)
vk = vk_session.get_api()
for event in longpoll.listen():
if event.type == VkEventType.MESSAGE_NEW and event.to_me and event.text:
if event.text == '1st variant of phrase' or event.text == '2nd variant of phrase':
if event.from_user:
vk.messages.send(
user_id=event.user_id,
message='Ваш текст'
)
elif event.from_chat:
vk.messages.send(
chat_id=event.chat_id,
message='text'
)
break
continue
File "C:\Users\тандер\Desktop\bot.py", line 14, in <module>
longpoll = VkLongPoll(vk_session)
File "D:\Programs\Python\Python38\lib\site-packages\vk_api\longpoll.py", line 517, in __init__
self.update_longpoll_server()
File "D:\Programs\Python\Python38\lib\site-packages\vk_api\longpoll.py", line 531, in update_longpoll_server
response = self.vk.method('messages.getLongPollServer', values)
File "D:\Programs\Python\Python38\lib\site-packages\vk_api\vk_api.py", line 646, in method
raise 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
We made changes to the VK API. Now unverified developers can't get access to send messages. Information here: https://vk.com/dev/messages_api
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question