PHP code example of chronoarc / marvel
1. Go to this page and download the library: Download chronoarc/marvel library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
chronoarc / marvel example snippets
$publicKey = 'your-public-key-here';
$privateKey = 'your-private-key-here';
$marvel = new Chronoarc\Marvel\Marvel($publicKey, $privateKey);
$superhero = ['name' => 'Spider-Man (Peter Parker)', 'id' => 1009610];
$characters = $marvel->characters()->search(name: $superhero['name']);
$characters->dto(); // Chronoarc\Marvel\Dto\CharacterDataWrapper
$character = $marvel->characters()->getCharacter($superhero['id']);
$character->dto(); // Chronoarc\Marvel\Dto\CharacterDataWrapper
$characterSeries = $marvel->characters()->getCharacterSeries($superhero['id']);
$characterSeries->dto(); // Chronoarc\Marvel\Dto\SeriesDataWrapper
$characterComics = $marvel->characters()->getCharacterComics($superhero['id']);
$characterComics->dto(); // Chronoarc\Marvel\Dto\ComicDataWrapper
$characterEvents = $marvel->characters()->getCharacterEvents($superhero['id']);
$characterEvents->dto(); // Chronoarc\Marvel\Dto\EventDataWrapper
$characterStories = $marvel->characters()->getCharacterStories($superhero['id']);
$characterStories->dto(); // Chronoarc\Marvel\Dto\StoryDataWrapper
use Chronoarc\Marvel\Enums\Comic\OrderBy;
use Chronoarc\Marvel\Enums\Comic\Format;
...
/** @var ComicDataWrapper $comics */
$comics = $this->connector->comics()->search(
format: Format::comic,
orderBy: [OrderBy::titleAsc],
)->dto();