1
出于安全原因,我的网络主机不支持file_get_contents,但确实支持使用cURL。任何人都可以告诉我,现在我会用curl来转换这个短代码吗?我一直在努力尝试好几天,所以任何帮助将不胜感激!使用cURL代替file_get_contents
<?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";
?>
http://www.php.net/manual/en/curl.examples-basic.php几乎总结使用率高达。 – m90
为什么你不使用Weather Underground API? –
$ ch = curl_init(“http://api.wunderground.com/api/b2b4a1ad0a889006/geolookup/q/IA/Cedar_Rapids.json”); $ responce = json_decode(curl_exec($ ch),true); –