How to display number of likes top user group VC?

0 like 0 dislike
40 views
The script displays the user who, most likes, put it on the wall of the group (displayed name, avatar)
public function getLikerId() { global $config; $users = []; $time_to = time(); if (!empty($config['like_interval']['to'])) { $time_to = strtotime($time_to); } $posts = $this->getPosts(-$config['group_id']); foreach ($posts as $post) { if ($post->date < strtotime($config['like_interval']['from']) || $post->date > $time_to) { continue; } $likes = $this->getLikes(-$config['group_id'], $post->id); foreach ($likes->users as $id) { if (isset($users[$id])) { $users[$id]++; } else { $users[$id] = 1; } } } arsort($users); $user_ids = array_keys($users); $user_id = array_shift($user_ids); return $user_id; } private function getLikes($owner_id = 1, $item_id = 1, $type = 'post') { return $this->api('likes.getList', [ 'owner_id' => $owner_id, 'item_id' => $item_id, 'type' => $type, ]); }

how to get the number of likes, how much he gave?
by | 40 views

1 Answer

0 like 0 dislike
1. To pass all posts using the method wall.get - Bad.
2. Using the CallBack API to receive notifications for likes set by the user and save them on the server (preferably in the database) - Good.
by

Related questions

0 like 0 dislike
1 answer
asked May 4, 2019 by ivan99
0 like 0 dislike
2 answers
0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
110,608 questions
257,186 answers
0 comments
33,605 users