I round up the test and the way your code is it gives an error message like this:
SSL Certificate problem: Unable to get local Issuer Certificate
then to get around that which is the verification of the SSL
configure your code to not do this check:
$details_url = 'https://newsapi.org/v2/everything?q=video-games&apiKey=minhachave';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $details_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // aqui a alteração
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); // aqui a alteração
$result = json_decode(curl_exec($ch), true);
echo '<pre>';
print_r($result);
from these two settings the result is returned. A recommended reading on: PHP CURL issues "Unable to get local Issuer Certificate" error here on the site itself.
Observing: I recommend this only in a test environment, in production usually the servers have the certificate and can be used without these settings and remember that security is a topic debated and should exist to help maintain a healthy system.
Summary: your code requires verification SSL
where your server is not configured correctly and the result is not brought, showing the error reported in this response and an example code was made that can be used in your test environment, but, not recommended in the production environment, for the reason security guard.
Thank you, I’ll test!
– Ricardo Gonçalves