PHP:Yahoo Weather Api 使用 file_get_content 得到空结果

PHP: Yahoo Weather Api getting empty result with file_get_content

我正在从我的网页进行 ajax 调用,以从 getWeather.php 页面获取 JSON 格式的响应。有时我得到结果,但大多数时候我没有。但是每当我浏览这个 link 时,它总是给我 JSON 格式的结果。我的 getWeather.php 是不是做错了什么?

https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%27lahore%27)%20AND%20u%3D%27c%27&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=

getWeather.php 实施:

<?php
$city = $_GET['city'];

echo file_get_contents("https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%27".$city."%27)%20AND%20u%3D%27c%27&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=");


?>

{"query":{"count":0,"created":"2017-01-03T04:50:27Z","lang":"en-US","results":null}}

雅虎天气 API 有问题。你可以在雅虎上查看; https://developer.yahoo.com/weather/ 自己的应用程序也有同样的问题。