greenreader9 / mofh-client
PHP 的 WHM API 客户端,用于 MyOwnFreeHost
v1.0.0
2023-08-14 22:05 UTC
Requires
- php: >=7.1
- ext-json: *
- ext-simplexml: *
- guzzlehttp/guzzle: ~6.0|~7.0
Requires (Dev)
- fakerphp/faker: ^1.7
- friendsofphp/php-cs-fixer: ^3.4
- mockery/mockery: ^1.3
- phpunit/phpunit: ^7.0|^8.0|^9.0
README
一个 API 客户端,用于使用来自 MyOwnFreeHost 的免费托管系统。基于 InfinityFree 的 API 包装器。
重要提示:此库面向经验丰富的 PHP 开发者。需要具备面向对象 PHP 和 Composer 的经验。如果您不能使用 oo-PHP 和 Composer,则无需考虑此库。
安装
建议通过 Composer 安装此包
composer require Greenreader9/mofh-client
用法
在您开始之前,您需要从 MyOwnFreeHost 获取 API 凭证。登录到 经销商面板,转到 API -> 设置 WHM API -> 选择您要配置的域名。复制 API 用户名和 API 密码,并将您的 IP 地址设置为允许的 IP 地址(您的计算机、服务器或您想使用此 API 客户端的任何地方)。
可用方法
见客户端文件
示例
以下示例可能无法正常工作,因为客户端已进行修改。请参阅客户端文件,或使用 InfinityFreeHosting github 个人资料中的 mofh-wrapper。
use \Greenreader9\MofhClient\Client; // Create a new API client with your API credentials. $client = new Client("<MOFH API username>", "<MOFH API password>"); // Create a new hosting account. $createResponse = $client->createAccount( 'abcd1234', // A unique, 8 character identifier of the account. Primarily used as internal identifier. 'password123', // A password to login to the control panel, FTP and databases. 'user@example.com', // The email address of the user. 'userdomain.example.com', // Initial domain of the account. Can be a subdomain or a custom domain. 'my_plan', // The hosting plan name at MyOwnFreeHost. ); // Check whether the request was successful. if ($createResponse->isSuccessful()) { echo "Created account with username: ".$createResponse->getVpUsername(); } else { echo 'Failed to create account: ' . $createResponse->getMessage(); die(); }
许可协议
版权 2023 Greenreader9/Hans Adema/InfinityFree
根据 Apache 许可协议版本 2.0(“许可”)授权;除非符合许可协议,否则不得使用此文件。您可以在以下位置获取许可协议的副本:
https://apache.ac.cn/licenses/LICENSE-2.0
除非适用法律要求或以书面形式同意,否则在许可下分发的软件按“现状”基础分发,不提供任何明示或暗示的保证或条件。有关许可协议中规定的许可和限制的具体语言,请参阅许可协议。