pete001 / frost-php-sdk
用于 Poet Frost API 的 PHP SDK
1.2
2018-02-16 08:22 UTC
Requires
- guzzlehttp/guzzle: ~6.0
- vlucas/phpdotenv: ^2.4
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.3
- mockery/mockery: 0.9.*
- phpmetrics/phpmetrics: ^2.2
- phpspec/phpspec: ~2.1
- phpunit/phpunit: ~5.0
This package is not auto-updated.
Last update: 2024-09-29 05:21:03 UTC
README
你觉得区块链很酷?勾选 √
你是想要在作品中盖章并保护版权的技术出版者?勾选 √
你觉得 Po.et 是完成这项任务最酷的平台?勾选 √
你无视了那些讨厌你的人,追求对甜美的 PHP 7 的热爱?勾选 √
好吧,听起来你确实在正确的位置!
背景
你已经通过了检查测试,所以你需要的是官方文档。
安装
composer require pete001/frost-php-sdk
配置
不要将私钥提交到版本控制,使用 .env 文件!
在这里注册并获取你的 API 密钥。
将其添加到项目根目录下的 .env
文件中。
用法
因为我喜欢圣诞节,所以我创建了一个简单的工厂来节省时间
$api = (new FrostFactory)->api();
到目前为止,有3个实用的方法
创建作品
$work = $api->createWork([ 'name' => 'I am a pickle', 'datePublished' => '2018-02-15T20:12:01+00:00', 'dateCreated' => '2018-02-14T19:50:21+00:00', 'author' => 'Pickle Rick', 'tags' => 'pickle rick morty unimpressed', 'content' => 'Rick tells Morty to come to the garage, and Morty discovers that Rick has turned himself into a pickle but is unimpressed.' ]); print_r($work); Array ( [workId] => 46b6144b7fc6825caa3cf4b83149226f8d3f7bc0b20e6780c5d80423d1a5b86a )
获取作品
$work = $api->getWorkById('46b6144b7fc6825caa3cf4b83149226f8d3f7bc0b20e6780c5d80423d1a5b86a'); print_r($work); Array ( [name] => I am a pickle [datePublished] => 2018-02-15T20:12:01+00:00 [dateCreated] => 2018-02-14T19:50:21+00:00 [author] => Pickle Rick [tags] => pickle rick morty unimpressed [content] => Rick tells Morty to come to the garage, and Morty discovers that Rick has turned himself into a pickle but is unimpressed. )
获取所有作品
$work = $api->getWorks(); print_r($work); Array ( [0] => Array ( [name] => I am a pickle [datePublished] => 2018-02-15T20:12:01+00:00 [dateCreated] => 2018-02-14T19:50:21+00:00 [author] => Pickle Rick [tags] => pickle rick morty unimpressed [content] => Rick tells Morty to come to the garage, and Morty discovers that Rick has turned himself into a pickle but is unimpressed. ) [1] => Array ( [name] => I am still a pickle [datePublished] => 2018-02-15T21:12:01+00:00 [dateCreated] => 2018-02-14T20:50:21+00:00 [author] => Pickle Rick [tags] => pickle rick morty unimpressed repetitive [content] => Rick tells Morty once again, to come to the garage, and Morty discovers that Rick is still a pickle. He remains unimpressed. ) )
测试
项目具有100%的测试覆盖率,但由于我个性的原因,持续集成在 Gitlab 上运行。所以,你只需相信我。
要运行测试套件,只需执行
vendor/bin/phpunit
如果你想要检查代码覆盖率
vendor/bin/phpunit --coverage-html tests/coverage
如果你和我一样有强迫症,你可能想要运行一些静态分析
vendor/bin/phpmetrics --report-html="tests/static" .
贡献
欢迎所有贡献!只需发起一个 PR 并发誓代码通过了测试,有新测试编写以保持100%覆盖率,并确保其符合 PSR-2 规范
vendor/bin/php-cs-fixer fix --verbose
许可
虽然很诱人,但用集中式的方式来分发去中心化世界的应用……这是免费的,对所有人都免费!
MIT 许可证