dborsatto / php-giantbomb
一个作为 GiantBomb API 封装的 PHP 库。
v2.2.0
2021-06-17 10:33 UTC
Requires
- php: ^7.4|^8.0
- ext-json: *
- ext-mbstring: *
- cache/void-adapter: ^1.0
- guzzlehttp/guzzle: ^6.2|^7.0
- psr/simple-cache: ^1.0
Requires (Dev)
- cache/array-adapter: ^1.0
- friendsofphp/php-cs-fixer: ^2.16
- phpspec/phpspec: ^6.2
- vimeo/psalm: ^3.15
README
这是一个作为 GiantBomb API 封装的库。
安装
通过 Composer
$ composer require dborsatto/php-giantbomb
使用方法
$apiKey = 'YouApiKey'; // Create a Config object and pass it to the Client $config = new DBorsatto\GiantBomb\Configuration($apiKey); $client = new DBorsatto\GiantBomb\Client($config); // OPTIONAL: use a PSR-16 simple cache pool $cache = new Cache\Adapter\PHPArray\ArrayCachePool(); $client = new DBorsatto\GiantBomb\Client($config, $cache); // Standard query creation process $query = DBorsatto\GiantBomb\Query::create() ->addFilterBy('name', 'Uncharted') ->sortBy('original_release_date', 'asc') ->setFieldList(['id', 'name', 'deck']) ->setParameter('limit', '100') ->setParameter('offset', '0'); $games = $client->find('Game', $query); echo count($games)." Game objects loaded\n"; // These two options are equivalent $game = $client->findOne('Game', Query::createForResourceId('3030-22420')); // The findWithResourceID method is just a shortcut $game = $client->findWithResourceID('Game', '3030-22420'); echo $game->get('name')." object loaded\n"; // These two options are equivalent $query = DBorsatto\GiantBomb\Query::create() ->setParameter('query', 'Uncharted') ->setParameter('resources', 'game,franchise'); $results = $client->find('Search', $query); // The search method is just a shortcut $results = $client->search('Uncharted', 'game,franchise'); echo count($results)." Search objects loaded\n";
要查看完整选项列表,请访问 GiantBomb API 文档。
许可证
MIT 许可证 (MIT)。有关更多信息,请参阅 许可证文件。