出于安全原因,我的虚拟主机不支持 file_get_contents,但支持使用 cURL。谁能告诉我现在我会使用 curl 转换这个短代码吗?我已经尝试了好几天没有运气,所以任何帮助将不胜感激!
<?php
$json_string = file_get_contents("http://api.wunderground.com/api/b2b4a1ad0a889006/geolookup
/conditions/q/IA/Cedar_Rapids.json");
$parsed_json = json_decode($json_string);
$location = $parsed_json->{'location'}->{'city'};
$temp_f = $parsed_json->{'current_observation'}->{'temp_f'};
echo "Current temperature in ${location} is: ${temp_f}\n";
?>