Coder Social home page Coder Social logo

marvel-api-client's Introduction

Marvel API Client

Build Status Code Quality Code Coverage

Latest Stable Version Latest Unstable Version License

Total Downloads Daily Downloads Monthly Downloads

A PHP client for use with the Marvel API.

Requirements

The Marvel API Client requires PHP 7.0 (or later).

Composer

To add the library as a local, per-project dependency use Composer! Simply add a dependency on chadicus/marvel-api-client to your project's composer.json file such as:

composer require chadicus/marvel-api-client

Examples

Examples of use can be found here

Basic Usage

<?php

require_once __DIR__ . '/vendor/autoload.php';

use Chadicus\Marvel\Api\Client;

$publicApiKey = 'YOUR PUBLIC API KEY';
$privateApiKey = 'YOUR PRIVATE API KEY';

$client = new Client($privateApiKey, $publicApiKey);

$dataWrapper = $client->get('characters', 1009351);

//Text to display for attribution requirements
$attributionText = $dataWrapper->getAttributionText();

$character = $dataWrapper->getData()->getResults()[0];

echo "{$character->getName()}\n";
echo "{$character->getDescription()}\n";

foreach ($character->getEvents()->getItems() as $event) {
    echo "\t{$event->getName()}\n";
}

Community

Gitter

Contact

Developers may be contacted at:

Project Build

With a checkout of the code get Composer in your PATH and run:

composer install
./vendor/bin/phpunit

With Great Power Comes Great Responsibility.

When using the marvel-api-client you must follow Marvel's Rules of Attribution

marvel-api-client's People

Contributors

chadicus avatar scrutinizer-auto-fixer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

marvel-api-client's Issues

Update coveralls dependency

satooshi/php-coveralls has become php-coveralls/php-coveralls. The dev dependencies should be updated accordingly.

PHP 7

Please update composer.json to allow installation for PHP 7

Cannot Search for Series or Stories

Hello,

I am having an issue using the client->search() function to retrieve stories or series.

protected function getItems(Character $character, $itemType)
{
    $comicWrapper = $this->client->search($itemType, [
        'characters' => $character->id,
        'limit'      => 40
    ]);
    return $comicWrapper->getData()->getResults();
}

Expected Behavior

if $itemType = 'comics this function returns an array or comics
if $itemType = 'events this function returns an array or events
if $itemType = 'stories' this function returns an array or stories
if $itemType = 'series' this function returns an array or series

Actual Behavior

if $itemType = 'comics this function returns an array or comics
if $itemType = 'events this function returns an array or events

if $itemType = 'stories' && $itemType = 'series' produce the following error:

PHP Fatal error:  Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Type error: Argument 1 passed to Chadicus\Marvel\Api\Entities\AbstractEntity::fromArray() must be of the type array, null given in /home/tim/ContinuumTest/vendor/chadicus/marvel-api-client/src/Entities/AbstractEntity.php:109
Stack trace:
#0 [internal function]: Chadicus\Marvel\Api\Entities\AbstractEntity::fromArray(NULL)

#1 /home/tim/ContinuumTest/vendor/dominionenterprises/filter/src/Filterer.php(166): call_user_func_array('\\Chadicus\\Marve...', Array)

#2 /home/tim/ContinuumTest/vendor/chadicus/marvel-api-client/src/Filterer.php(53): DominionEnterprises\Filterer::filter(Array, Array, Array)

#3 /home/tim/ContinuumTest/vendor/chadicus/marvel-api-client/src/Entities/AbstractEntity.php(29): Chadicus\Marvel\Api\Filterer::filter(Array, Array, Array)

#4 /home/tim/ContinuumTest/vendor/chadicus/marvel-api-client/src/Entities/AbstractEntity.php(96): Chadicus\Marvel\Api\Entities\AbstractEntity->__construct(Array)

#5 [internal function]: Chadicus\Marvel\Ap in /home/tim/ContinuumTest/vendor/chadicus/marvel-api-client/src/Entities/AbstractEntity.php on line 109

Implement skip($offset) method

Implement a skip() method which would set a starting offset for the collection. It could return itself or a clone of itself with an absolute limit

/**
 * Return a collection with the given $offset
 *
 * @param integer $offset
 *
 * @return Collection
 */
public function skip($offset)
{
}

Implement Collection::take($limit)

Implement a take() method which would set an absolute limit in the collection. It could return itself or a clone of itself with an absolute limit

/**
 * Return a collection limited to $limit number of items
 *
 * @param integer $limit
 *
 * @return Collection
 */
public function take($limit)
{
}

limit & offset filters overriden ?

Hi, I'm using your lib to pull comics for a serie and I can't seem to be able to paginate results,
passing 'limit' & 'offset' keys to the "filters" array when creating a new Collection object always returns all of comics and not the ones included in the limits.
could you help me out please ?
Thanks for providing this lib though.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.