headers: {
'Content-type': 'application/json',
'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept, Authorization',
'Access-Control-Allow-Methods': 'GET, DELETE, HEAD, OPTIONS',
Authorization: `Bearer ${token}`,
}
from vk_api import VkApi, AuthError
from vk_api.utils import get_random_id
vk_session = VkApi(login = {login}, password = {pass})
vk_session.auth(token_only=True)
vk = vk_session.get_api()
for friend in vk.friends.get()['items']:
res = vk.messages.send(user_id=friend, message='Сообщение', random_id=get_random_id())
from vk_api import VkApi, AuthError
from vk_api.utils import get_random_id
vk_session = VkApi(login = {мой логин}, password = {мой пароль})
vk_session.auth(token_only=True)
vk = vk_session.get_api()
vk.messages.send(user_id={мой ID}, message='Сообщение', random_id=get_random_id())