PHP code example of slacker775 / knowbe4-kmsat-api
1. Go to this page and download the library: Download slacker775/knowbe4-kmsat-api 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/ */
slacker775 / knowbe4-kmsat-api example snippets
$KNOWBE4_API_TOKEN = '12345';
$bearerAuth = new BearerAuthAuthentication(
$KNOWBE4_API_TOKEN
);
$httpClient = getHttpClient([new AuthenticationRegistry([$bearerAuth])]);
$apiClient = \KnowBe4\Kmsat\Api\Client::create($httpClient);
$result = $apiClient->getAccount();
function getHttpClient(array $additionalPlugins = []): PluginClient
{
$httpClient = Psr18ClientDiscovery::find();
$plugins = [];
$uri = Psr17FactoryDiscovery::findUrlFactory()->createUri(
'https://us.api.knowbe4.com'
);
$plugins[] = new AddHostPlugin($uri);
if (count($additionalPlugins) > 0) {
$plugins = array_merge($plugins, $additionalPlugins);
}
return new PluginClient($httpClient, $plugins);
}