Answer the question
In order to leave comments, you need to log in
Why do endless vk longpoll server requests come?
The code:
import requests
class Bot:
def __init__(self, token):
url = f'https://api.vk.com/method/groups.getLongPollServer?group_id=203187908&access_token={token}&v=5.130'
self.res = requests.get(url).json()['response']
self.longpoll = f'{self.res["server"]}?act=a_check&key={self.res["key"]}&ts={self.res["ts"]}&wait=25'
def check(self):
return requests.get(self.longpoll).json()['updates']
token = 'TOKEN'
vk = Bot(token)
while True:
print(vk.check())
Answer the question
In order to leave comments, you need to log in
because
ts is the number of the last event, starting from which data should be received;
__init__
and continue to receive updates on it. Update ts on every request, it comes in this response you get Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question