peakhour-io/peakhour-api

此包的最新版本(0.1.0)没有可用的许可证信息。

用于 https://www.peakhour.io/api/explore/ 的 PHP 客户端

0.1.0 2024-09-16 22:40 UTC

This package is not auto-updated.

Last update: 2024-10-02 19:51:24 UTC


README

使用 Guzzle 实现的用于 https://www.peakhour.io/api/explore/ 的 PHP 客户端

安装

composer require peakhour-io/peakhour-api

(以及通常的 )

使用方法

$client = (new \PeakhourIo\Client(['base_uri' => 'https://www.peakhour.io']))
    ->setAuthApiKey('<API_KEY>')
    ->setDomain('www.example.com');
$response = $client->domains()->flushResources([
    '/about',
    '/blog/1337
]);

$code = $response->getStatusCode();
if ($code !== 202) {
    // Error handling (...)
}

杂项

此客户端的设计灵感来源于 https://github.com/opensearch-project/opensearch-php,但更简单。目的是通过遵循 API 客户端的常见设计,在应用程序中实现一个易于使用和直观的库。Peakhour.io/api 是一个包含 140 个端点的庞大 API。在当前阶段,此客户端实现了 2 个端点(清除功能)。根据需要,可以将其扩展到更多端点。

该库采用命名空间的概念,将端点分组到功能组中,从而降低复杂性。连接部分是围绕 Guzzle 的轻量级包装,模仿其接口并处理身份验证和数据编码。