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

Call to undefined function Unirest\curl_init()

Slauf21 opened this issue · comments

Hey

When I call matecritic.php I get this fatal error: Call to undefined function Unirest\curl_init(). I have the php_curl.dll file under my php extensions. Ive also added my php directory in the system variable "path". I should probably note that im trying to call this script from a c++ program.

Could you maybe help me with this?

Did you also try example.php?

I have, It gives the same results.

OK. Can you give me some details about your setup. Are you using php in apache. Or command line (php cli) or?

Which version of php?

Etc.

Im using php in command line. For now, all my c++ program does is simulate a command line. It calls example.php and passes an argument (game name) to the script and should receive the JSON output echo. I have the following version of php installed: PHP 8.1.4 (cli) (built: Mar 16 2022 09:32:18) (NTS Visual C++ 2019 x64).

OK. So I can't reproduce the problem on my Linux machine with PHP cli. So PHP 8 should work.

The only option would be that curl is not enabled. Did you remove the semi-colon(;) in front of the extension=php_curl.dll line?

EDIT: Also keep in mind there are different php.ini files depending on FPM, Apache or CLI (command line).

You can validate whether cURL is enabled or not in PHP using and check the output:

<?php
phpinfo();
?>

Add this content to a phpinfo.php file for example.

The following output (or at least something similar) should be preset in the output of php phpinfo.php:

image

If not, you did NOT enable PHP curl. Again check if the dll is present and enabled it (removing the ;) in all your PHP.ini files.

I have a php.ini-development file and a php.ini-production file. extension=php_curl.dll was absent in both files so i just added it myself. There was a line in both files ;extension=curl and I removed the ; in both. The result is the same. I executed the phpinfo() and there is only one instance of curl mentioned:
image. Its not like your output even tough I removed the ; .

I have a php.ini-development file and a php.ini-production file. extension=php_curl.dll was absent in both files so i just added it myself. There was a line in both files ;extension=curl and I removed the ; in both. The result is the same. I executed the phpinfo() and there is only one instance of curl mentioned: image. Its not like your output even tough I removed the ; .

You are using windows right? Do not enable this other line please. That is for Linux only. Only apply the extension lines with dll at the end.

I think I managed to solve it.
image
Loaded Configuration File => was empty, so I just changed the php.ini-development file to php.ini. Now I dont get this error anymore.

Ah great. Good job.