L
L
leistolz2016-03-25 22:15:49
Python
leistolz, 2016-03-25 22:15:49

Why doesn't it wait for long poll server response in python?

Hello, there is such a problem: when using a long poll connection to VK, the code does not wait for the server's response, and starts doing everything again, the code itself:

import requests
import re
import vk
import urllib.request
while True:
    url = "https://api.vk.com/method/messages.getLongPollServer?need_pts=1&access_token=xxx"
    response = requests.request('GET', url)
    response = response.text
    response = str(response)
    key = response[20:62]
    ts = response[99:109]
    pts = response[116:122]
    print(response)
    url = 'https://imv4.vk.com/im6096?act=a_check&key=' + key + '&ts=' + ts + '&pts=' + pts + 'wait=25&mode=8'
    response = requests.request('GET', url, timeout=25)
    response = response.text
    response = str(response)
    response = response.replace("b'", '')
    print('resp', response)

Everything was calm in PHP, I don’t immediately understand why it doesn’t expect a response :\

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anatoly, 2017-10-22
@trofimovdev

Honestly - too lazy to understand.
Here is my sample implementation of LongPoll: click .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question