nspyke / ehive
EHive API 客户端
1.0.2
2017-08-29 00:50 UTC
Requires
- php: >=5.6.0
- ext-curl: *
- psr/log: ^1.0
- psr/simple-cache: ^1.0
Requires (Dev)
- internations/http-mock: 0.8.1
- phpunit/phpunit: ^4.0 || ^5.0
- squizlabs/php_codesniffer: ^3.0
Suggests
- monolog/monolog: Compatible logging library
- symfony/cache: Caching library for most types of caching providers (Memcached, Redis, APCu etc)
This package is auto-updated.
Last update: 2024-09-24 15:27:26 UTC
README
这是 Vernon Systems 于 2017 年 8 月发布的 EHive PHP 客户端版本 2.1.2 的分支,遵循 GPL v2 许可证。此库已发布在 GPL v3 许可证下。
此分支增加了命名空间、Packagist 和 Composer 支持、PSR-4 自动加载、PSR-16 缓存、PSR-3 日志记录,以及 90% 以上的单元测试覆盖率。
使用方法
use EHive\ApiClient; use EHive\Transport\Transport; $transport = new Transport( 'your_client_id', 'your_client_secret', 'your_tracking_id' ); $client = new ApiClient($transport);
然后调用 ApiClient 对象上的方法以获取相关域对象。
缓存(可选)
已实现 PSR-16 简单缓存以缓存 GET 请求。我们推荐使用 symfony/cache,但可以使用任何实现。您可以通过查找提供 psr/simple-cache-implementation 虚拟软件包的软件包来找到实现。
使用方法
$cache = new MyCache(); // which implements \Psr\SimpleCache\CacheInterface $transport = new Transport(...); $transport->setCache($cache); $client = new ApiClient($transport);
日志记录(可选)
还实现了 PSR-3 日志记录以记录错误。我们推荐使用 monolog/monolog。
使用方法
$logger = new MyLogger(); // which implements \Psr\Log\LoggerInterface $transport = new Transport(...); $transport->setLogger($logger); $client = new ApiClient($transport);
API 客户端方法
账户
/** @var EHive\Domain\Account\Account $account */ $account = $client->getAccount($accountId); $account = $client->getAccountInCommunity($communityId, $accountId); /** @var EHive\Domain\Account\AccountsCollection $accountsCollection */ $accountsCollection = $client->getAccountsInEHive($query, $sort, $direction, $offset = 0, $limit = 10); $accountsCollection = $client->getAccountsInCommunity($communityId, $query, $sort, $direction, $offset = 0, $limit = 10);
社区
/** @var EHive\Domain\Community\CommunitiesCollection $communitiesCollection */ $communitiesCollection = $client->getCommunitiesModeratoredByAccount($accountId); $communitiesCollection = $client->getCommunitiesInEHive($query, $sort, $direction, $offset = 0, $limit = 10);
对象记录
/** @var EHive\Domain\ObjectRecord\ObjectRecord $objectRecord */ $objectRecord = $client->getObjectRecord($objectRecordId); /** @var EHive\Domain\ObjectRecord\ObjectRecordsCollection $objectRecordsCollection */ $objectRecordsCollection = $client->getObjectRecordsInEHive($query, $hasImages = false, $sort, $direction, $offset = 0, $limit = 10); $objectRecordsCollection = $client->getObjectRecordsInAccount($accountId, $query, $hasImages = false, $sort, $direction, $offset = 0, $limit = 10, $content = "public"); $objectRecordsCollection = $client->getObjectRecordsInCommunity($communityId, $query, $hasImages = false, $sort, $direction, $offset = 0, $limit = 10); $objectRecordsCollection = $client->getObjectRecordsInAccountInCommunity($communityId, $accountId, $query, $hasImages = false, $sort, $direction, $offset = 0, $limit = 10);
有趣的对象记录
/** @var EHive\Domain\ObjectRecord\ObjectRecordsCollection $objectRecordsCollection */ $objectRecordsCollection = $client->getInterestingObjectRecordsInEHive($hasImages = false, $catalogueType = "", $offset = 0, $limit = 10); $objectRecordsCollection = $client->getInterestingObjectRecordsInAccount($accountId, $catalogueType = "", $hasImages = false, $offset = 0, $limit = 10, $content = "public"); $objectRecordsCollection = $client->getInterestingObjectRecordsInCommunity($communityId, $catalogueType = "", $hasImages = false, $offset = 0, $limit = 10); $objectRecordsCollection = $client->getInterestingObjectRecordsInAccountInCommunity($communityId, $accountId, $catalogueType = "", $hasImages = false, $offset = 0, $limit = 10);
流行的对象记录
/** @var EHive\Domain\ObjectRecord\ObjectRecordsCollection $objectRecordsCollection */ $objectRecordsCollection = $client->getPopularObjectRecordsInEHive($hasImages = false, $catalogueType = "", $offset = 0, $limit = 10); $objectRecordsCollection = $client->getPopularObjectRecordsInAccount($accountId, $catalogueType = "", $hasImages = false, $offset = 0, $limit = 10, $content = "public"); $objectRecordsCollection = $client->getPopularObjectRecordsInCommunity($communityId, $catalogueType = "", $hasImages = false, $offset = 0, $limit = 10); $objectRecordsCollection = $client->getPopularObjectRecordsInAccountInCommunity($communityId, $accountId, $catalogueType = "", $hasImages = false, $offset = 0, $limit = 10);
最近的对象记录
/** @var EHive\Domain\ObjectRecord\ObjectRecordsCollection $objectRecordsCollection */ $objectRecordsCollection = $client->getRecentObjectRecordsInEHive($hasImages = false, $catalogueType = "", $offset = 0, $limit = 10); $objectRecordsCollection = $client->getRecentObjectRecordsInAccount($accountId, $catalogueType = "", $hasImages = false, $offset = 0, $limit = 10, $content = "public"); $objectRecordsCollection = $client->getRecentObjectRecordsInCommunity($communityId, $catalogueType = "", $hasImages = false, $offset = 0, $limit = 10); $objectRecordsCollection = $client->getRecentObjectRecordsInAccountInCommunity($communityId, $accountId, $catalogueType = "", $hasImages = false, $offset = 0, $limit = 10);
对象评论
/** @var EHive\Domain\Comment\CommentsCollection $commentsCollection */ $commentsCollection = $client->getObjectRecordComments($objectRecordId, $offset = 0, $limit = 10); /** @var EHive\Domain\Comment\Comment $comment */ // Create and set the object and its values via the public properties $comment = new Comment(); ... $comment = $client->addObjectRecordComment($objectRecordId, $comment);
对象记录标签
/** @var EHive\Domain\ObjectRecordTag\ObjectRecordTagsCollection $objectRecordTagsCollection */ $objectRecordTagsCollection = $client->getObjectRecordTags($objectRecordId); /** @var EHive\Domain\ObjectRecordTag\ObjectRecordTag $objectRecordTag */ // Create and set the object and its values via the public properties $tag = new ObjectRecordTag(); ... $objectRecordTag = $client->addObjectRecordTag($objectRecordId, $tag); $objectRecordTag = $client->deleteObjectRecordTag($objectRecordId, ObjectRecordTag $tag);
标签云
/** @var EHive\Domain\TagCloud\TagCloud $tagCloud */ $tagCloud = $client->getTagCloudInEHive($limit = 10); $tagCloud = $client->getTagCloudInAccount($accountId, $limit = 10); $tagCloud = $client->getTagCloudInCommunity($communityId, $limit = 10);