/group-stats
, которая выводит статсы по каждой группе и сумму во всех группах. В узле "Данные VK API" вставить id групп, для которых выводить данные, в "Мой акк" - свой токен для доступа к VK API и готово.[
{
"id": "1a53fed2.b20021",
"type": "change",
"z": "398791b.201f36e",
"name": "Данные VK API",
"rules": [
{
"t": "set",
"p": "apiData.group_ids",
"pt": "msg",
"to": "business,donut",
"tot": "str"
},
{
"t": "set",
"p": "apiData.fields",
"pt": "msg",
"to": "members_count",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 600,
"y": 380,
"wires": [
[
"4baee50a.80781c"
]
]
},
{
"id": "4baee50a.80781c",
"type": "drom-vk-api-call",
"z": "398791b.201f36e",
"name": "Получ инфо о группах",
"data": "apiData",
"dataType": "msg",
"method": "groups.getById",
"methodType": "str",
"property": "payload",
"client": "f6e8a943.b2d388",
"apiV": "5.126",
"x": 630,
"y": 420,
"wires": [
[
"e8e387ac.a92108"
]
]
},
{
"id": "bb769f50.7776f",
"type": "drom-template",
"z": "398791b.201f36e",
"name": "HTML",
"field": "payload",
"fieldType": "msg",
"syntax": "handlebars",
"htmlEscape": true,
"template": "<html>\n<head></head>\n<body>\n<ul>\n{{#each payload}}\n<li>{{this.name}} - {{this.members_count}}</li>\n{{/each}}\n</ul>\n\n<p>\n Всего: {{total}}\n</p>\n</body>\n</html>",
"x": 1090,
"y": 380,
"wires": [
[
"4ebdbb53.73c5f4"
]
]
},
{
"id": "e7643afd.a46498",
"type": "http in",
"z": "398791b.201f36e",
"name": "",
"url": "/group-stats",
"method": "get",
"upload": false,
"swaggerDoc": "",
"x": 360,
"y": 400,
"wires": [
[
"1a53fed2.b20021"
]
]
},
{
"id": "4ebdbb53.73c5f4",
"type": "http response",
"z": "398791b.201f36e",
"name": "",
"statusCode": "",
"headers": {},
"x": 1090,
"y": 420,
"wires": []
},
{
"id": "e8e387ac.a92108",
"type": "change",
"z": "398791b.201f36e",
"name": "Сумма всех",
"rules": [
{
"t": "set",
"p": "total",
"pt": "msg",
"to": "$sum(payload.members_count)\t",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 870,
"y": 400,
"wires": [
[
"bb769f50.7776f"
]
]
},
{
"id": "f6e8a943.b2d388",
"type": "drom-vk-api-config",
"apiV": "5.126",
"name": "Мой акк"
}
]
var groups = "apiclub,55293029"; // сюда подставить ваши группы
var counts = API.groups.getById({
group_ids: groups,
fields: "members_count",
})@.members_count;
var total = 0;
while (counts.length > 0) total = total + counts.pop();
return total;
$code = <<<EOFVK
var groups = "apiclub,55293029";
var counts = API.groups.getById({
group_ids: groups,
fields: "members_count",
})@.members_count;
var total = 0;
while (counts.length > 0) total = total + counts.pop();
return total;
EOFVK;
// токен сообщества получить в Настройках своего сообщества, Работа с API
// нажать кнопку Создать ключ и выбрать любую галочку.
$token = '123123123';
$method = 'execute';
$params = [
'access_token' => $token,
'v' => '5.130',
];
$post_data = [
'code' => $code,
];
$url = sprintf(
'https://api.vk.com/method/%s?%s',
$method,
http_build_query($params)
);
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => $url,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $post_data,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 10,
]);
$curl_result = curl_exec($ch);
$data = json_decode($curl_result);
$count = $data->response;
printf('<h2>Сейчас в группах %d участников</h2>', $count);