<?php
$apiKey = "your-api-key";
$email = "[email protected]";
$endpoint = "https://portal.hostraha.com/modules/addons/DomainsReseller/api/index.php";
$token = base64_encode(hash_hmac("sha256", $apiKey, "{$email}:" . gmdate("y-m-d H")));
function call(string $url, string $email, string $token): string {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
"username: {$email}",
"token: {$token}",
]);
$response = curl_exec($curl);
curl_close($curl);
return $response;
}
echo call("{$endpoint}/billing/credits", $email, $token) . "\n";
echo call("{$endpoint}/version", $email, $token) . "\n";