0

On my Windows 10 machine, I run some PHP scripts that call API functions on a game, Torn. Torn allows and encourages the call of such API.

Since a few days, all my command line scripts stopped working from my machine.

I verified this both running them from the command line, and setting a quick web server with php -s

Both modalities were working earlier.

The scripts running on a separate websites still work.

I suspect the cause may be a recent Windows update.

What am I doing wrong, and how do I fix this?

I tried with PHP version 7.4.6 and 8.4.4, CLI, NTS, x64

Here is the code, and the result:

<?php

$jsonurl = "https://api.torn.com/faction/16335?selections=basic&key=aaa";
$json = file_get_contents( $jsonurl ) ; //gets output of API
$decodedString = json_decode( $json, true ) ; //parses API JSON output
print_r( $decodedString ) ;
?>


PHP Warning:  file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages:
error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed in C:\Users\borre\OneDrive\work\torn\apitest.php on line 4

Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages:
error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed in C:\Users\borre\OneDrive\work\torn\apitest.php on line 4
PHP Warning:  file_get_contents(): Failed to enable crypto in C:\Users\borre\OneDrive\work\torn\apitest.php on line 4

Warning: file_get_contents(): Failed to enable crypto in C:\Users\borre\OneDrive\work\torn\apitest.php on line 4
PHP Warning:  file_get_contents(https://api.torn.com/faction/16335?selections=basic&key=aaa): failed to open stream: operation failed in C:\Users\borre\OneDrive\work\torn\apitest.php on line 4

Warning: file_get_contents(https://api.torn.com/faction/16335?selections=basic&key=aaa): failed to open stream: operation failed in C:\Users\borre\OneDrive\work\torn\apitest.php on line 4
4
  • 1
    Your PHP is too old. Upgrade it. Commented Feb 13 at 8:33
  • Do you have a reason to think this is the cause of the problem? Commented Feb 13 at 21:03
  • I installed 8.44, set allow_url_fopen=on, extension=openssl in php.ini I get the same error Commented Feb 13 at 21:58
  • 1
    Well, that's strange, I just tested it with PHP 8.2 on Windows 10 and it worked... Commented Feb 14 at 8:20

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.