/** * Constructor of DrHost, * define output format and api key * * @param String $apiKey */ public function __construct($apiKey) { Dreamhost::setOutputFormat($this->outputFormat); Dreamhost::setApiKey($apiKey); }
<?php require __DIR__ . '/../vendor/autoload.php'; use Dreamhost\Dreamhost; (new Dotenv\Dotenv(dirname(__DIR__)))->load(); Dreamhost::setOutputFormat(getenv('DREAMHOST_OUTPUT')); Dreamhost::setApiKey(getenv('DREAMHOST_KEY'));
private static function buildUrl($command, $params = []) { $url = rtrim(Dreamhost::apiBaseUrl(), '/') . '?'; return $url . http_build_query(array_replace_recursive(['key' => Dreamhost::apiKey(), 'unique_id' => uniqid(), 'cmd' => $command, 'format' => Dreamhost::outputFormat()], (array) $params)); }