Laravel PHP Facade/Wrapper for the IGDB API

1.0.0 2017-08-06 17:14 UTC

This package is auto-updated.

Last update: 2024-09-29 05:01:16 UTC


README

Build Status Built For Laravel License Total Downloads

简介

本包提供了一个方便的IGDB API包装器,便于在Laravel应用程序中使用。

为了使用IGDB API,您必须有一个账户和密钥。您可以在 https://api.igdb.com/ 注册您的应用程序。

安装

messerli90/igdb 添加到您的 composer.json

"messerli90/igdb": "~1.0"

或者

composer require messerli90/igdb

运行 composer update 以获取包的最新版本。

现在打开 app/config/app.php 并将服务提供者添加到您的 providers 数组中。

'providers' => array(
    Messerli90\IGDB\IGDBServiceProvider::class,
)

可选地,将外观添加到您的 aliases 数组

'IGDB' => \Messerli90\IGDB\Facades\IGDB::class,

配置

igdb 添加到您的 config/services.php 数组中。将缓存设置为分钟数以缓存响应。

'igdb' => [
    'key' => 'YOUR_IGDB_KEY',
    'url' => 'YOUR_IGDB_URL',
    'cache' => 0
]

使用方法

// Get Game by ID
$game = IGDB::getGame(9630);

// Customize / limit the returned fields
$games = IGDB::getGame(9630, ['name', 'release_dates', 'esrb', 'genres'], $limit = 10, $offset = 0, $order = 'release_dates.date:desc');

// Search Games by name
$games = IGDB::searchGames('fallout');

// Get Character by ID
$character = IGDB::getCharacter(4534);

// Search Characters by name
$characters = IGDB::searchCharacters('fisher');

// Get upcoming releases
$releases = IGDB::getReleases($filters = ['filter[platform][eq]=48', 'filter[date][gt]=1500619813000], $fields = ['*'], $limit = 10, $offset = 0, $order = 'date:asc');

// Get Company by ID
$companies = IGDB::getCompany('ubisoft');

// Search Company by name
$company = IGDB::getCompany(7041);

// Get Franchise by ID
$franchise = IGDB::getFranchise(133);

// Search Franchise by name
$franchises = IGDB::searchFranchises('Harry Potter');

// Get Game Mode by Id
$game_mode = IGDB::getGameMode(1);

// Search Game Modes by name
$game_modes = IGDB::searchGameModes('Single Player');

// Get Genre by ID
$genre = IGDB::getGenre(15);

// Search Genres by name
$genres = IGDB::searchGenres('strategy');

// Get Keyword by ID
$keyword = IGDB::getKeyword(121);

// Search Keyword by name
$keywords = IGDB::searchKeywords('sandbox');

// Get Person by ID
$person = IGDB::getPerson(24354);

// Search People by name
$people = IGDB::searchPeople('Delaney');

// Get Platform by ID
$platform = IGDB::getPlatform(49);

// Search Platforms by name
$platforms = IGDB::searchPlatforms('xbox');

// Get Player Perspective by ID
$player_perspective = IGDB::getPlayerPerspective(7);

// Search Player Perspective by name
$player_perspectives = IGDB::searchPlayerPerspectives('Virtual');

// Get Pulse by ID
$pulse = IGDB::getPulse(20707);

// Fetch latest Pulses
$pulses = IGDB::fetchPulses();

// Get Collection / Series by ID
$collection = IGDB::getCollection(3);

// Search Collections / Series by name
$collections = IGDB::searchCollections('fallout');

// Get Theme by ID
$theme = IGDB::getTheme(39);

// Search Themes by name
$themes = IGDB::searchThemes('warfare');

返回数据的格式

返回的JSON数据被解码为PHP对象。

运行单元测试

如果您的环境中已安装PHPUnit,运行

$ phpunit

IGDB API

贡献

请参阅 CONTRIBUTING 以获取详细信息。

鸣谢

许可证

MIT许可证(MIT)。请参阅 许可证文件 以获取更多信息。