northern-lights / polr-client
Polr API 客户端
1.0.1
2019-02-22 14:12 UTC
Requires
- php: >=7.0
- ext-json: *
- guzzlehttp/guzzle: ^6.3
- illuminate/support: ^5.5
- psr/http-message: ^1.0
- symfony/serializer: ^4.2
- zendframework/zend-config: ^3.2
Requires (Dev)
- jakub-onderka/php-console-highlighter: ^0.4.0
- jakub-onderka/php-parallel-lint: ^1.0
- phpstan/phpstan: ^0.9.2
- phpunit/php-invoker: ^1.1
- phpunit/phpunit: ^6.5
- roave/security-advisories: dev-master
- squizlabs/php_codesniffer: ^3.3
- symfony/var-dumper: ^3.4
This package is auto-updated.
Last update: 2024-09-23 02:28:23 UTC
README
简介
PHP 编写的 cydrobolt/polr REST API 客户端
提供与 Polr 实例交互的简单接口
用法
一个非常简单的示例,使用默认配置
<?php namespace NorthernLights\Client\Polr\Example; use NorthernLights\Client\Polr\ApiClient; use NorthernLights\Client\Polr\Config\Config; use NorthernLights\Client\Polr\Response\ShortenResponseInterface; /** * Initialize API client and pass $config to it (DI) * @var ApiClient $api */ $api = new ApiClient(); /** * Shorten the long URL. * @var ShortenResponseInterface $response */ $response = $api->shorten('https://www.polrproject.org'); // Check if API request was successful. Remains true as long as HTTP status code equals 200 OK if (!$response->wasSuccessful()) { echo 'There was an error querying the api' . PHP_EOL; exit(1); } echo 'Short URL is ' . $response->getShortUrl() . PHP_EOL;
有关更详细示例和配置,请参阅 示例。所有使用场景都涵盖在内。
- 配置
- 查找 [/api/v2/action/lookup]
- 缩短 [/api/v2/action/shorten]
- 批量缩短 [/api/v2/action/shorten_bulk]
- 数据 [/api/v2/data/link]
安装
建议通过 Composer 安装
composer require northern-lights/polr-client
或者,您可以从中下载最新稳定版本 发布。
请注意,此库不附带自动加载器,但依赖于 Composer 内置的自动加载器。
行业标准与最佳实践
库努力遵守行业中的最新标准和最佳实践,因此我们包含了以下内容
PSR-2 编码标准合规性检查 & 修复
我们希望代码尽可能好
$ composer check-style $ composer fix-style
注意:第二个命令实际上会修改文件
代码语法检查(lint)
非常基本的检查,可以节省我们很多麻烦
$ composer php-lint
静态代码分析
这样我们可以尽早捕捉到错误。
$ composer phpsam
单元测试
这样我们可以确保所有部件都在顺利运行
$ composer test
待办事项
- 实现 批量缩短 [/api/v2/action/shorten_bulk]
- 添加单元测试
- 添加详细的 API 文档
免责声明
本项目或其作者与 Polr 项目 或任何第三方无关。
许可证
MIT 许可证 (MIT)。有关更多信息,请参阅 许可证文件。