maglr / noun-project-php-client
一个用于与Noun Project接口的PHP客户端
1.0.4
2021-08-23 14:15 UTC
Requires
Requires (Dev)
- phpunit/phpunit: ^7.0
This package is auto-updated.
Last update: 2024-09-18 03:24:51 UTC
README
安装
composer require maglr/noun-project-php-client
用法
将一个 NounProject\Request
传递给 NounProject\Client
以从API接收数据。您将收到一个 MattyRad\Support\Result
。
示例
use Maglr\NounProject; $api = new NounProject\Client($key = 'abc123', $secret= 'xxxx'); $result = $api->send(new NounProject\Request\Icons($term = 'feather', $public_domain = true)); if (! $result->isSuccess()) { throw new \Exception($result->getReason()); } $icons = $result->getIcons();
API和请求类型
集合
返回单个集合(通过集合ID或缩略名)
$result = $api->send(new NounProject\Request\Collection($collection_id_or_slug = 123)); $collection = $result->getCollection();
返回与集合关联的图标列表(通过集合ID或缩略名)
$result = $api->send(new NounProject\Request\IconsInCollection( $collection_id_or_slug = 123, $offset = 1, $page = 2, $limit = 3 )); $icons = $result->getIcons();
集合
返回所有集合的列表
$result = $api->send(new NounProject\Request\Collections($offset = 2, $page = 3, $limit = 1000)); $collections = $result->getCollections();
图标
返回单个图标
$result = $api->send(new NounProject\Request\Icon($icon_id_or_term = 123)); $icon = $result->getIcon();
图标
返回图标列表
$result = $api->send(new NounProject\Request\Icons( $icon_id_or_term = 'feather' $limit_to_public_domain = true; $offset = 2; $page = 3; $limit = 4; )); $icon = $result->getIcons();
返回最近上传的图标列表
$result = $api->send(new NounProject\Request\RecentIcons); $icon = $result->getIcons();
用法
返回当前OAuth使用情况和限制
$result = $api->send(new NounProject\Request\Usage); $usage = $result->getUsage(); $limits = $result->getLimits();