Google Workspace PHP SDK
This is Vendasta's official PHP SDK for API integration of Google Workspace.
- PHP 5.5 and above or PHP 7.0 and above
- PECL (may be used to install the required PHP extensions)
- Composer
- PHP gmp extension
- OPTIONAL (but recommended): PHP grpc extension
Install the requirements from above, then:
composer require vendasta/gsuite
To authenticate your SDK calls, you must provision a service account from within the Vendasta platform.
You must put this file on your server, and set an environment variable to its path:
export VENDASTA_APPLICATION_CREDENTIALS=<path to credentials.json>
It is highly recommended that you use a singleton client instance. Each client initialization will open its own connection, therefore using a singleton results in reusing a connection, saving time and resources.
Set an environment variable:
export ENVIRONMENT=<DEMO or PROD>
To instantiate the client:
$environment = getenv("ENVIRONMENT");
if ($environment == null) {
$environment = "DEMO";
}
$client = new Vendasta\GSuite\V1\PartnerClient($environment);
Notice that the environment will be set to DEMO if it is not specified.
$req = new GSuite\V1\GetDomainInformationRequest();
$req->setDomain("<domain>");
$resp = $client->GetDomainInformation($req);
If needed, a list of subscriptions and their SKU IDs can be found here.
$req = new ListSubscriptionsRequest();
$req->setDomain("<domain>");
$resp = $client->ListSubscriptions($req);
$subscriptions = $resp->getSubscriptions();
$subscriptionID = $subscriptions[0]->getSubscriptionId();
$req = new ChangeSeatsRequest();
$req->setCustomerId("<domain>");
$req->setSubscriptionId($subscriptionID);
$req->setSeats(1);
$resp = $client->ChangeSeats($req);
$req = new UpdateSSORequest();
$req->setDomain("<domain>");
// disable SSO
$req->setEnableSso(false);
$resp = $client->UpdateSSO($req);