melroy89 / metacritic_api

PHP Metacritic API - Mirror from my GitLab

Home Page:https://gitlab.melroy.org/melroy/metacritic_api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fatal error: Class 'MetacriticAPI' not found

felmur opened this issue · comments

Hi,

I've installed the directory metacritic_api in the root of my website.

So, i call example.php from browser:

https://mywebsite/metacritic_api/example.php.

The results is:
Fatal error: Uncaught Error: Class 'MetacriticAPI' not found in /srv/http/metacritic_api/example.php:7 Stack trace: #0 {main} thrown in /srv/http/metacritic_api/example.php on line 7

Where am I doing wrong?

Regards.

Are you sure you did put metacritic.php next to the example.php file?

You could try: new MetacriticAPI\MetacriticAPI() on line 7: https://github.com/danger89/metacritic_api/blob/master/example.php#L7

Are you sure you did put metacritic.php next to the example.php file?

yes, files metacritic.php and example.php are in the same directory

You could try: new MetacriticAPI\MetacriticAPI() on line 7:

[felice@asus metacritic_api]$ ls
composer.json example.php LICENSE phpcs.xml psalm.xml
composer.lock libs metacritic.php phpmetrics.json README.md

==========> this is output with normal line 7

[felice@asus metacritic_api]$ php example.php 
PHP Fatal error:  Uncaught Error: Class 'MetacriticAPI' not found in /srv/http/metacritic_api/example.php:7
Stack trace:
#0 {main}
  thrown in /srv/http/metacritic_api/example.php on line 7

Fatal error: Uncaught Error: Class 'MetacriticAPI' not found in /srv/http/metacritic_api/example.php:7
Stack trace:
#0 {main}
  thrown in /srv/http/metacritic_api/example.php on line 7

==========> now I edit example.php file how you suggested
[felice@asus metacritic_api]$ vi example.php
==========> this is output now

[felice@asus metacritic_api]$ php example.php 
PHP Fatal error:  Uncaught Error: Class 'MetacriticAPI\Unirest\Request' not found in /srv/http/metacritic_api/metacritic.php:36
Stack trace:
#0 /srv/http/metacritic_api/example.php(8): MetacriticAPI\MetacriticAPI->getMetacriticPage('the-elder-scrol...')
#1 {main}
  thrown in /srv/http/metacritic_api/metacritic.php on line 36


Fatal error: Uncaught Error: Class 'MetacriticAPI\Unirest\Request' not found in /srv/http/metacritic_api/metacritic.php:36
Stack trace:
#0 /srv/http/metacritic_api/example.php(8): MetacriticAPI\MetacriticAPI->getMetacriticPage('the-elder-scrol...')
#1 {main}
  thrown in /srv/http/metacritic_api/metacritic.php on line 36
[felice@asus metacritic_api]$ php --version
PHP 7.4.6 (cli) (built: May 12 2020 15:48:23) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

OK, I indeed fixed the namespace issues (see latest master). Next problem is that Metacritics changes their site.

Now it works and you are right: the result of the value of users and metascore is always 0 and a lot of json result is empty.

Anyway, in the meanwhile I fixed that myself, see master branch again. It should now all work again as expected!