Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env python
- # -*- coding: utf-8 -*-
- import vk_api, requests, random, json, datetime, re, time
- '''session_user = requests.Session()
- login, password = 'pass', 'pass'
- vk_session = vk_api.VkApi(login, password)'''
- vk_session = vk_api.VkApi(token='token')
- from vk_api.longpoll import VkLongPoll, VkEventType
- longpoll = VkLongPoll(vk_session)
- vk = vk_session.get_api()
- try:
- for event in longpoll.listen():
- if event.type == VkEventType.MESSAGE_NEW:
- if event.from_user:
- t=event.text
- t=t.encode('utf-8')
- id=str(event.user_id)
- now = datetime.datetime.utcnow()
- v=now.strftime("%d-%m-%Y %H:%M ")
- f = open("/root/out_from_user.txt", "a")
- f.write("@$#% " + v + " user_id: " + id + " soo: " + t + "\r\n")
- f.close()
- except Exception as e:
- print str(e)
- CODE OF ERROR:
- Traceback (most recent call last):
- File "/root/Downloads/j.py", line 13, in <module>
- longpoll = VkLongPoll(vk_session)
- File "/usr/local/lib/python2.7/dist-packages/vk_api/longpoll.py", line 503, in __init__
- self.update_longpoll_server()
- File "/usr/local/lib/python2.7/dist-packages/vk_api/longpoll.py", line 513, in update_longpoll_server
- response = self.vk.method('messages.getLongPollServer', values)
- File "/usr/local/lib/python2.7/dist-packages/vk_api/vk_api.py", line 636, in method
- raise error
- vk_api.exceptions.ApiError: [15] Access denied: no access to call this method
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement