newman/draugiem-php-sdk

基于 Guzzle 的 PHP Draugiem.lv API 库

1.0.0 2023-01-25 10:36 UTC

This package is auto-updated.

Last update: 2024-08-30 01:55:18 UTC


README

这不是官方库!

这是一个使用 Guzzle 客户端和严格类型对原始 API 库进行微小重写的版本。

需求

  • PHP 7.4+

安装

通过 Composer 需求此包

composer require newman/draugiem-php-sdk

📖 文档 & 使用

进行 API 调用

响应是 Psr\Http\Message\ResponseInterface 的实现。

$draugiemApi = new \Newman\DraugiemPhpSdk\DraugiemApi(1234, 'app key');
//$draugiemApi = new \Newman\DraugiemPhpSdk\DraugiemApi(1234, 'app key', 'user key');

$response = $draugiemApi->apiCall('authorize', ['code' => 5728195]);

var_dump($response->getStatusCode());
var_dump($response->getBody()->getContents());

设置默认 Guzzle 客户端选项

$draugiemApi = new \Newman\DraugiemPhpSdk\DraugiemApi(1234, 'app key');
$draugiemApi->setDefaultGuzzleClientOptions([
    'timeout' => 10,
    'headers' => [
        'User-Agent' => 'testing/1.0',
    ],
]);

// make an api call

🤝 贡献

我们非常感谢您对这个包的合作。

在提交拉取请求时,请确保:

  • 所有测试都通过: composer test
  • 测试覆盖率没有降低: composer test-coverage
  • 没有 PHPStan 错误: composer phpstan
  • 遵循编码标准: composer lintcomposer fix-style 以自动修复。