ikoene / marvel-api-client
An API client to handle calls to the Marvel API.
Requires
- doctrine/collections: ^1.3
- guzzle/guzzle: ^3.9
- jms/serializer: ^1.3
- symfony/yaml: ^3.1
Requires (Dev)
- phpspec/phpspec: ^3.0
This package is not auto-updated.
Last update: 2024-11-09 20:12:26 UTC
README
Marvel API client
The Marvel Comics API allows developers everywhere to access information about Marvel's vast library of comics—from what's coming up, to 70 years ago. This Marvel API client helps you explore the Marvel universe with great ease.
Requirements
- PHP 7.0.0
- Marvel API key
- Love for Marvel
Installation
Add the API client as a dependency to your project using Composer.
composer require ikoene/marvel-api-client
Usage
<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use ikoene\Marvel\Client;
$client = new Client('your_public_api_key', 'your_private_api_key');
$response = $client->getCharacter(1009610);
var_dump($response);
Endpoints
You can call every endpoint with an explicitly defined method. So if you, for example, want a list of comics containing a specific character, you can call getComicsForCharacter()
.
$response = $client->getComicsForCharacter(1009610);
Optional filters
It's also possible to add optional filters to the calls. Let's get all comics for 'Spider-Man' which title starts with 'Age of Ultron' and order the results by 'title'.
$comicFilter = new \ikoene\Marvel\Entity\ComicFilter();
$comicFilter->setTitleStartsWith('Age of Ultron');
$comicFilter->setOrderBy('title');
$response = $client->getComicsForCharacter(1009610, $comicFilter);
Pretty easy, right?
Examples
You can find some more examples here.