Something strange is happening, and I would like to know why.
At this URL: http://api.promasters.net.br/cotacao/v1/valores?moedas=USD&alt=json , which works fine in the browser, but when I tried to get the content using php:
echo file_get_contents('http://api.promasters.net.br/cotacao/v1/valores?moedas=USD&alt=json');
Nothing printed, var_dump(...) = string(0) ""so I went a little further and used:
function get_page($url) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, True);
curl_setopt($curl, CURLOPT_URL, $url);
$return = curl_exec($curl);
curl_close($curl);
return $return;
}
echo get_page('http://api.promasters.net.br/cotacao/v1/valores?moedas=USD&alt=json');
Nothing is printed either, so I tried python (3.X):
import requests
print(requests.get('http://api.promasters.net.br/cotacao/v1/valores?moedas=USD&alt=json').text)
AND WORKING. Why is this happening? What's happening?
source
share