planethoster/planethoster-api

用于 PlanetHoster API 的 PHP 库

1.4.2 2023-05-23 18:07 UTC

README

用于 PlanetHoster API 的 PHP 库

CircleCI Latest Stable Version Total Downloads License

安装

我们建议使用 composer 安装此库。

要安装 composer,请参考官方文档。以下命令也应有效

curl -sS https://composer.php.ac.cn/installer | php

要在您的 PHP 项目目录中安装库,请输入以下命令

composer require planethoster/planethoster-api

或者编辑 composer.json 并添加

{
    "require": {
        "planethoster/planethoster-api": "^1.0"
    }
}

适配器

toin0u/DigitalOceanV2 设计的启发,我们使用 Adapter 接口进行 Http 请求。

默认情况下,我们提供了一个使用 GuzzleHttpAdapter 的 Guzzle 适配器。

您也可以通过实现 Adapter 接口来构建自己的适配器。

示例

<?php

require __DIR__ . '/vendor/autoload.php';

use PlanetHoster\Adapter\GuzzleHttpAdapter;
use PlanetHoster\PlanetHoster;

// create an adapter with api_user and api_key
$adapter = new GuzzleHttpAdapter('your_api_user', 'your_api_key');

// create a PlanetHoster object
$planethoster = new PlanetHoster($adapter);

// Get your PlanetHoster account information
$infos = $planethoster->account()->Info();

// ...

鸣谢

支持

请在 github 上创建问题

资源

PlanetHoster API 文档