1. Go to this page and download the library: Download brickservers/gsuite library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use BrickServers\GoogleWorkspace\GoogleWorkspace;
// Via facade or service container
$workspace = app('google-workspace');
// Or using dependency injection
public function __construct(GoogleWorkspace $workspace)
{
$this->workspace = $workspace;
}
$user = $workspace->users()->get('[email protected]');
// With projection and view type
use BrickServers\GoogleWorkspace\Enums\UserProjection;
use BrickServers\GoogleWorkspace\Enums\UserViewType;
$user = $workspace->users()->get(
'[email protected]',
projection: UserProjection::FULL,
viewType: UserViewType::ADMIN_VIEW,
);
$result = $workspace->users()->list(maxResults: 100);
$users = $result['users']; // Array of UserDTO
$nextPageToken = $result['nextPageToken']; // For pagination
UserProjection::BASIC // Basic information only
UserProjection::FULL // Full user information
UserProjection::CUSTOM // Custom schema information
UserViewType::ADMIN_VIEW // Admin perspective
UserViewType::DOMAIN_PUBLIC // Public domain view
ApiScope::DIRECTORY_USER
ApiScope::DIRECTORY_GROUP
ApiScope::CLASSROOM_COURSES
ApiScope::CALENDAR
ApiScope::GMAIL_COMPOSE
ApiScope::DRIVE
// ... and more