hansadema/mofh-client

此包已被废弃,不再维护。作者建议使用 infinityfree/mofh-client 包。

PHP版的MyOwnFreeHost WHM API客户端

0.4.0 2019-11-07 19:47 UTC

README

这是一个用于使用MyOwnFreeHost免费托管系统的API客户端。

重要:此库面向经验丰富的PHP开发者。需要具备面向对象PHP和Composer的经验。如果您不能使用oo-PHP和Composer,请不要使用此库。

安装

此包最好通过Composer安装

composer require hansadema/mofh-client

使用方法

在开始之前,您需要从MyOwnFreeHost获取API凭证。登录到 经销商面板,转到API -> 设置WHM API -> 选择您要配置的域名。复制API用户名和API密码,并将您的IP地址设置为允许的IP地址(您的计算机、服务器或您想要使用此API客户端的任何地方)。

MyOwnFreeHost API公开以下方法。以下列出了可用参数。

  • createAccount
    • username: 账户的唯一8位标识符。
    • password: 用于登录控制面板、FTP和数据库的密码。
    • domain: 要创建账户的域名。可以是子域名或自定义域名。
    • email: 用户的电子邮件地址。
    • plan: 创建账户的托管计划名称。需要在MyOwnFreeHost中配置托管包。
  • suspend
    • username: 账户的唯一8位标识符。
    • reason: 包含您暂停账户原因的字符串。
    • linked: 如果为true,则相关账户也将被暂停。
  • unsuspend
    • username: 账户的唯一8位标识符。
  • password
    • username: 账户的唯一8位标识符。
    • password: 为账户设置的新密码。
  • availability
    • domain: 要检查的域名或子域名。
  • getUserDomains
    • username: vistaPanel登录用户名(例如abcd_12345678)。

示例

use \HansAdema\MofhClient\Client;

// Create a new API client with your API credentials.
$client = Client::create([
    'apiUsername' => 'your_api_username',
    'apiPassword' => 'your_api_password',
    'plan' => 'my_plan', // Optional, you can define it here or define it with the createAccount call.
]);

// Create a request object to create the request.
$request = $client->createAccount([
    'username' => 'abcdefgh', // A unique, 8 character identifier of the account.
    'password' => 'password123', // A password to login to the control panel, FTP and databases.
    'domain' => 'userdomain.example.com', // Can be a subdomain or a custom domain.
    'email' => 'user@example.com', // The email address of the user.
    'plan' => 'my_plan', // Optional, you can submit a hosting plan here or with the Client instantiation.
]);

// Send the API request and keep the response.
$response = $request->send();

// Check whether the request was successful.
if ($response->isSuccessful()) {
   echo 'You can login as: ' . $response->getVpUsername();
} else {
   echo 'Failed to create account: ' . $response->getMessage();
}

许可协议

版权所有2019年Hans Adema

根据Apache许可证版本2.0(“许可证”)许可;除非符合许可证规定或书面同意,否则不得使用此文件。您可以在以下位置获得许可证副本:

https://apache.ac.cn/licenses/LICENSE-2.0

除非适用法律要求或书面同意,否则在许可证下分发的软件按“原样”提供,不提供任何明示或暗示的保证或条件。请参阅许可证了解具体语言的权限和限制。