From ed7faa4a160f55b84f4201803795098577f27aa4 Mon Sep 17 00:00:00 2001 From: Vladimir Lapskiy <94683384+el-psy-congroo-desu@users.noreply.github.com> Date: Sat, 17 Sep 2022 02:05:25 +0500 Subject: [PATCH] VKAPI: Friends.getRequests added some parameters that i forgot about and fix count requests in the response (#724) * VKAPI: Friends.getRequests method did not give more than 6 elements * VKAPI: Friends.getRequests i'm forget add some parameters LOL --- VKAPI/Handlers/Friends.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/VKAPI/Handlers/Friends.php b/VKAPI/Handlers/Friends.php index ca9b7573..20c537a5 100644 --- a/VKAPI/Handlers/Friends.php +++ b/VKAPI/Handlers/Friends.php @@ -133,15 +133,18 @@ final class Friends extends VKAPIRequestHandler return $response; } - function getRequests(string $fields = "", int $offset = 0, int $count = 100): object + function getRequests(string $fields = "", int $offset = 0, int $count = 100, int $extended = 0): object { + if ($count >= 1000) + $this->fail(100, "One of the required parameters was not passed or is invalid."); + $this->requireUser(); $i = 0; $offset++; $followers = []; - foreach($this->getUser()->getFollowers() as $follower) { + foreach($this->getUser()->getFollowers($offset, $count) as $follower) { $followers[$i] = $follower->getId(); $i++; } @@ -149,8 +152,10 @@ final class Friends extends VKAPIRequestHandler $response = $followers; $usersApi = new Users($this->getUser()); - if(!is_null($fields)) - $response = $usersApi->get(implode(',', $followers), $fields, 0, $count); # FIXME + if($extended == 1) + $response = $usersApi->get(implode(',', $followers), $fields, 0, $count); + else + $response = $usersApi->get(implode(',', $followers), "", 0, $count); foreach($response as $user) $user->user_id = $user->id;