我是否遗漏了什么,或者这是否应该起作用?
$weatherAPI = "api.openweathermap.org/data/2.5/weather?zip=" . $zipCode . ",us&APPID=myAPI";
$json = file_get_contents($weatherAPI);
$weatherData = json_decode($json,true);
echo $weatherData["main"]["temp"];
发布于 2018-06-15 23:51:46
至少,您必须在URL中使用"http/https“:
$weatherAPI = "http://api.openweathermap.org/data/2.5/weather?zip=" . $zipCode . ",us&APPID=myAPI";
如果您有任何问题,请提供JSON响应和错误。
https://stackoverflow.com/questions/50878892
复制相似问题