danielcosta / php-dreamhost
此软件包已被废弃,不再维护。未建议替代软件包。
用于Dreamhost API的PHP类
1.0.0
2013-08-22 13:38 UTC
This package is not auto-updated.
Last update: 2020-01-19 16:00:06 UTC
README
与Dreamhost API接口
安装
该软件包在 Composer 上可用。自动加载与 PSR-0 兼容。
使用
<?php
use DanielCosta\Dreamhost;
$dh = new Dreamhost('your api key'[,format]);
$dh->exec('command'[, array(arg => value[, ...])]);
其中 '命令' 是在 Dreamhost Wiki API 文章中列出的众多命令之一。
方法 'exec' 返回由Dreamhost返回的数据的关联数组数组,或在出错时抛出异常。
您可以通过传递给类构造函数的第二个参数来定义任何首选的返回格式。默认为 'json'。
示例
<?php
use DanielCosta\Dreamhost;
$dh = new Dreamhost('6SHU5P2HLDAYECUM'[,format]);
try {
$method = 'api-list_accessible_cmds';
$commands = $dh->exec($method);
// $commands = $dh->$method(); // this should also work
print_r($commands);
} catch (Exception $e) {
echo $e->getMessage(); // contains either the error data returned by dreamhost or a curl error string and number
}