2
I have the following code in my PHP
:
<?php
$url = "https://api.cartolafc.globo.com/mercado/destaques";
$response = file_get_contents($url);
$jogadores = json_decode($response,true);
It should return the file json
, where I gather the information and assemble on another page and it worked until a while ago, but it stopped. and absolutely nothing was changed.
How can I solve this problem?
When I use:
var_dump(json_decode($response, true));
He only returns NULL
You’re not making the mistake
failed to open stream
using the functionfile_get_contents
?– Woss
Gave yes :/ but with the reply of the friend below, it worked :)
– André Luiz Mardonis
In these cases, when the error message appears, put it along with the question, as it makes it easier for anyone to help you understand the problem. In this case it was not crucial, as it would be the most obvious mistake, but it is not always so, so do it in possible future questions.
– Woss
Blz Anderson, but the issue of Failed to open error... only appeared on one of my servers, in the main where the application runs did not show this error, simply returned NULL without showing any error, thank you. hugging
– André Luiz Mardonis
It must be the configuration of this server to hide the error messages. Generally servers that run in production are configured like this to avoid leaking some information to malicious users.
– Woss