Advertisement
Areafishing

error

May 4th, 2019
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.41 KB | None | 0 0
  1. #! /usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. import vk_api, requests, random, json, datetime, re, time
  5.  
  6. '''session_user = requests.Session()
  7. login, password = 'pass', 'pass'
  8. vk_session = vk_api.VkApi(login, password)'''
  9.  
  10. vk_session = vk_api.VkApi(token='token')
  11.  
  12. from vk_api.longpoll import VkLongPoll, VkEventType
  13. longpoll = VkLongPoll(vk_session)
  14. vk = vk_session.get_api()
  15. try:
  16.     for event in longpoll.listen():
  17.         if event.type == VkEventType.MESSAGE_NEW:
  18.             if event.from_user:
  19.                 t=event.text
  20.                 t=t.encode('utf-8')
  21.                 id=str(event.user_id)
  22.                 now = datetime.datetime.utcnow()
  23.                 v=now.strftime("%d-%m-%Y %H:%M ")
  24.                 f = open("/root/out_from_user.txt", "a")
  25.                 f.write("@$#% " + v + " user_id: " + id + " soo: " + t + "\r\n")
  26.                 f.close()
  27. except Exception as e:
  28.     print str(e)
  29.  
  30.  
  31. CODE OF ERROR:
  32. Traceback (most recent call last):
  33.   File "/root/Downloads/j.py", line 13, in <module>
  34.     longpoll = VkLongPoll(vk_session)
  35.   File "/usr/local/lib/python2.7/dist-packages/vk_api/longpoll.py", line 503, in __init__
  36.     self.update_longpoll_server()
  37.   File "/usr/local/lib/python2.7/dist-packages/vk_api/longpoll.py", line 513, in update_longpoll_server
  38.     response = self.vk.method('messages.getLongPollServer', values)
  39.   File "/usr/local/lib/python2.7/dist-packages/vk_api/vk_api.py", line 636, in method
  40.     raise error
  41. vk_api.exceptions.ApiError: [15] Access denied: no access to call this method
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement