mstdmstdd Posted February 10, 2018 Share Posted February 10, 2018 Hello,I want ot get weather information from yahooapis and I do like $BASE_URL = "http://query.yahooapis.com/v1/public/yql"; $yql_query = 'select wind from weather.forecast where woeid in (select woeid from geo.places(1) where text="chicago, il")'; $yql_query_url = $BASE_URL . "?q=" . urlencode($yql_query) . "&format=json"; // Make call with cURL $session = curl_init($yql_query_url); curl_setopt($session, CURLOPT_RETURNTRANSFER,true); $json = curl_exec($session); // Convert JSON to PHP object $phpObj = json_decode($json); var_dump($phpObj); I got this sample fromhttps://developer.yahoo.com/weather/#phpIt works ok for location I set in current time, what I did not find if this API gives possibility get data in next hours(days) ?If yes, please give ref ti this description...Also I created Consumer Key and Secret for my account, but in this example I do not use it...Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/306488-get-weather-information-from-yahooapis/ Share on other sites More sharing options...
requinix Posted February 10, 2018 Share Posted February 10, 2018 Their "database" structure doesn't seem to be documented anywhere, so judging by the examples: no, they don't provide an hourly forecast. At least not through that API. By the way, this code is much simpler than yours: $BASE_URL = "http://query.yahooapis.com/v1/public/yql"; $yql_query = 'select wind from weather.forecast where woeid in (select woeid from geo.places(1) where text="chicago, il")'; $phpObj = json_decode(file_get_contents($BASE_URL . "?" . http_build_query([ "q" => $yql_query, "format" => "json" ]))); var_dump($phpObj); Quote Link to comment https://forums.phpfreaks.com/topic/306488-get-weather-information-from-yahooapis/#findComment-1556224 Share on other sites More sharing options...
mstdmstdd Posted February 10, 2018 Author Share Posted February 10, 2018 Can you advice some well documented API with hourly forecast ? Quote Link to comment https://forums.phpfreaks.com/topic/306488-get-weather-information-from-yahooapis/#findComment-1556228 Share on other sites More sharing options...
requinix Posted February 11, 2018 Share Posted February 11, 2018 Nope. I don't know of any. Quote Link to comment https://forums.phpfreaks.com/topic/306488-get-weather-information-from-yahooapis/#findComment-1556246 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.