PHP code example of ixoplan / ixoplan-sdk
1. Go to this page and download the library: Download ixoplan/ixoplan-sdk 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/ */
ixoplan / ixoplan-sdk example snippets
use Ixolit\Dislo\Client;
use Ixolit\Dislo\HTTP\Guzzle\GuzzleHTTPClientAdapter;
use Ixolit\Dislo\Request\HTTPRequestClient;
$httpAdapter = new GuzzleHTTPClientAdapter();
$httpClient = new HTTPRequestClient(
$httpAdapter,
$host,
$apiKey,
$apiSecret
);
$apiClient = new Client($httpClient);
$apiClient = new \Ixolit\Dislo\Client($httpClient);
try {
$authResponse = $apiClient->userAuthenticate(
$userEmail,
$password,
$ipAddress
);
$authToken = $authResponse->getAuthToken();
setcookie('authToken', $authToken);
$user = $response->getUser();
echo $user->getLastLoginDate();
}
catch (\Ixolit\Dislo\Exceptions\AuthenticationInvalidCredentialsException $e) {
// invalid credentials
echo $e->getMessage();
}
$token = getcookie('authToken');
$apiClient = new \Ixolit\Dislo\Client($httpClient);
try {
$user = $apiClient->userGet($token);
}
catch (\Ixolit\Dislo\Exceptions\InvalidTokenException $e) {
// token invalid, e.g. expired
setcookie('authToken', null, -1);
}
catch (\Ixolit\Dislo\Exceptions\DisloException $e) {
// other, e.g. missing arguments
}
$token = getcookie('authToken');
$apiClient = new \Ixolit\Dislo\Client($httpClient);
try {
$response = $apiClient->userExtendToken($token, $ipAdress, 3600);
$authToken = $response->getAuthToken();
echo $authToken->getValidUntil()->format('c');
}
catch (\Ixolit\Dislo\Exceptions\InvalidTokenException $e) {
// token invalid, e.g. expired
setcookie('authToken', null, -1);
}
catch (\Ixolit\Dislo\Exceptions\DisloException $e) {
// other, e.g. missing arguments
}
$apiClient->userDeauthenticate($token);
setcookie('authToken', null, -1);
$apiClient = new \Ixolit\Dislo\Client($httpClient);
$response = $apiClient->packagesList("1");
foreach ($response->getPackages() as $package) {
echo $package->getDisplayNameForLanguage('en')->getName(), "\n";
}
$apiClient = new \Ixolit\Dislo\Client($httpClient);
$response = $apiClient->subscriptionGetAll($token);
foreach ($response->getSubscriptions() as $subscription) {
print_r([
'status' => $subscription->getStatus(),
'active' => $subscription->isActive(),
'startedAt' => $subscription->getStartedAt()->format('c'),
'package' => $subscription->getCurrentPackage()->getDisplayNameForLanguage('en')->getName(),
'price (EU)' => $subscription->getCurrentPeriod()->getBasePriceForCurrency('EUR')->getAmount(),
'metaData' => $subscription->getProvisioningMetaData(),
]);
}
$apiClient = new \Ixolit\Dislo\Client($httpClient);
$date = date('Y-m-d');
$file = fopen('/path/to/file', 'w');
$apiClient->exportStreamQuery(
'select * from users where last_indexed_at > :_last(date)',
['last' => $date],
$file
);