import requests
API = "https://api.vk.com/method"
ACCESS_TOKEN = "**********"
V = 5.80
response = requests.post(url=f"{API}/execute",
data={
"code": "var members = API.groups.getMembers({\"group_id\": \"tensor_company\"}).users;"
"var count = members.count;"
"var offset = 1000;"
"while (offset < count);"
"{;"
"members = members + \" , \" + API.groups.getMembers({\"group_id\": \"tensor_company\", \"offset\": offset}).users;"
"offset = offset + 1000;"
"};"
"return members;",
"access_token": ACCESS_TOKEN,
"v": V,
})
print(response.json())
{'error': {'error_code': 13, 'error_msg': 'Runtime error occurred during code invocation: Too many operations', 'request_params': [{'key': 'group_id', 'value': 'tensor_company'}]}}
Внутри code может содержаться не более 25 обращений к методам API.
var step=1000, R, offset = parseInt(Args.offset), loop=0,
out = { oid: parseInt(Args.oid), ids:[], mass: parseInt(Args.mass), overlap: parseInt(Args.overlap), offset: 0, next: 0 };
while( offset <= out.mass && loop < 25) {
R = API.groups.getMembers({ "group_id": out.oid, "sort": "id_asc", "offset": offset, "count": step});
if( !!R.items && R.items.length > 0) {
out.ids.push( R.items);
out.mass = R.count;
out.loop = loop;
out.offset = offset;
offset = offset + step - out.overlap;
out.next = offset;
loop = loop + 1;
} else {
out.error = "Empty items";
out.r = R;
return out;
}
}
return out;