VKAPI: added method friends.getRequests and fix code style (#653)

This commit is contained in:
El psy congroo desu 2022-08-14 14:43:04 +05:00 committed by GitHub
parent 0e1a672c27
commit b117d0fe01
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -23,9 +23,8 @@ final class Friends extends VKAPIRequestHandler
$usersApi = new Users($this->getUser());
if(!is_null($fields)) {
if(!is_null($fields))
$response = $usersApi->get(implode(',', $friends), $fields, 0, $count); # FIXME
}
return (object) [
"count" => $users->get($user_id)->getFriendsCount(),
@ -133,4 +132,32 @@ final class Friends extends VKAPIRequestHandler
return $response;
}
}
function getRequests(string $fields = "", int $offset = 0, int $count = 100): object
{
$this->requireUser();
$i = 0;
$offset++;
$followers = [];
foreach($this->getUser()->getFollowers() as $follower) {
$followers[$i] = $follower->getId();
$i++;
}
$response = $followers;
$usersApi = new Users($this->getUser());
if(!is_null($fields))
$response = $usersApi->get(implode(',', $followers), $fields, 0, $count); # FIXME
foreach($response as $user)
$user->user_id = $user->id;
return (object) [
"count" => $this->getUser()->getFollowersCount(),
"items" => $response
];
}
}