canihavesomecoffee / theTVDbAPI

PHP implementation for the 2nd version of the TheTVDb API
ISC License
11 stars 8 forks source link

New client performs login right away #7

Closed ghost closed 4 years ago

ghost commented 4 years ago

So I was using Laravels CLI tool "Artisan", and I have a method to fetch episodes from TVDB based on it's show ID.

Now I noticed every time I ran artisan, also for unrelated commands it would perform a call to TVDB, today it errored out so the error was especially noticable:

vagrant@homestead:~/code/projectname$ php artisan

   Exception  : Got status code 504 from service at path /login

  at /home/vagrant/code/projectname/vendor/canihavesomecoffee/thetvdbapi/src/TheTVDbAPI.php:372
    368|             }
    369|             return $json['data'];
    370|         }
    371|
  > 372|         throw new Exception(
    373|             sprintf(
    374|                 'Got status code %d from service at path %s',
    375|                 $response->getStatusCode(),
    376|                 $path

  Exception trace:

  1   CanIHaveSomeCoffee\TheTVDbAPI\TheTVDbAPI::performAPICallWithJsonResponse("post", "/login", ["{"apikey":"API KEY"}"])
      /home/vagrant/code/projectname/vendor/canihavesomecoffee/thetvdbapi/src/Route/AuthenticationRoute.php:73

  2   CanIHaveSomeCoffee\TheTVDbAPI\Route\AuthenticationRoute::login("API KEY")
      /home/vagrant/code/projectname/Blacklight/processing/tv/TVDB.php:60

  Please use the argument -v to see more details.

Now it looks like Artisan loops through all custom command files, and mine had this package loaded:

use CanIHaveSomeCoffee\TheTVDbAPI\Exception\ResourceNotFoundException;
use CanIHaveSomeCoffee\TheTVDbAPI\Exception\UnauthorizedException;
use CanIHaveSomeCoffee\TheTVDbAPI\TheTVDbAPI;

and in the constructor:

$this->client = new TheTVDbAPI();
$this->client->setAcceptedLanguages(['en']);

If this by design?

canihavesomecoffee commented 4 years ago

@Fossil01 I removed your API key, but it's still in history of the edits...

I'll look into the actual issue this evening :)

ghost commented 4 years ago

Crap, forgot about that. Guess im making a new one now :p

canihavesomecoffee commented 4 years ago

I tried to reproduce this locally on my PC (set a breakpoint to the json request method), and just initialized the TVDbAPI and set the accepted languages, but I don't see any breakpoints being hit, so no code being triggered automatically.

Note that this is without any use of frameworks. Have you tried without artisan?

ghost commented 4 years ago

I will have another look.

ghost commented 4 years ago

I'll close this for now.