grz-gajda / comicvine-api

PHP class wrapper providing a simple and flexible methods to using ComicVine API.
https://packagist.org/packages/grzgajda/comicvine-api
6 stars 3 forks source link

Having Trouble Starting #2

Closed WilliamWelsh closed 6 years ago

WilliamWelsh commented 6 years ago

Hello, I'm not very experienced when it comes to PHP, so please forgive my ignorance. Before I start, I think you forgot an extra parenthesis in your README example.

$response = ComicVine::getCharacters() ->setFormat($responseFormat) ->setFilters(['name' => 'Batman'] ->setLimit(1) ->setFieldList(['api_detail_url']) ->getResponse();

->setFilters(['name' => 'Batman'] ->setFilters(['name' => 'Batman'])

If not, sorry. Anyway, I am having trouble starting this out. Like I said, I'm not experienced with PHP, so it is most likely a stupid fault. I apologize. I get "Fatal error: Class 'ComicVine' not found." Here:

`<?php //session_start();

include_once("src/ComicVine.php");

$apiKey = ComicVine::makeApiKey('');
ComicVine::register($instanceOfRegisterKey, $instanceOfConnection = null);
$responseFormat = ComicVine::createFormat('json');

$response = ComicVine::getCharacters()
    ->setFormat($responseFormat)
    ->setFilters(['name' => 'Batman'])
    ->setLimit(1)
    ->setFieldList(['api_detail_url'])
    ->getResponse();

echo $response;

?>`

grz-gajda commented 6 years ago

In file src/ComicVine.php, line 3, there is key namespace. Read more about it.

To fix your issue, you should have:

<?php include_once("src/ComicVine.php");

$apiKey = ComicVine\ComicVine::makeApiKey('');
$response = ComicVine\ComicVine::createFormat('json');

where first ComicVine is from namespace, the second one is class name.