Answer the question
In order to leave comments, you need to log in
How to pass list of user_id to request vk api?
It is necessary to pass user_id in a list in a cycle to a request for api vk. Below is an example of the current implementation.
api_link = ' https://api.vk.com/method/ '
method = 'users.get'
id_links = [] #list from user_id
field_list = [] #list of returned fields by user
params = {'user_ids': id_links,
'fields': field_list,
'lang': 3,
'access_token': access_token,
'v': '5.120'} #request parameters
start = 0 # sampling start
step = 5 # loop step, it is the size of the list that is passed to query
for user in range(start, len(id_links), step):
params['user_ids'] = user_list
user_info = requests.get(api_link + method, params=params).json()
start += step
user += step
In the current implementation, every fifth user is returned, but it is necessary that 5 users be transmitted in one request.
What needs to be corrected?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question