Search code examples
phpyahoo-api

yahoo weather api returns null


I'm working on yahoo weather system but yahoo api returns null result.

This code I get from here: https://developer.yahoo.com/weather/#php

$BASE_URL = "http://query.yahooapis.com/v1/public/yql";    
$yql_query = 'select * from weather.forecast where woeid in (SELECT woeid FROM geo.places WHERE text=('.$time->latitude.','.$time->longitude.'))';
$yql_query_url = $BASE_URL . "?q=" . urlencode($yql_query) . "&format=json&diagnostics=true&callback=";
// 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);

When I enter this url in browser then it returns required result.

valid result return weather system correctly

https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(SELECT%20woeid%20FROM%20geo.places%20WHERE%20text=%22(40.7141667,-74.0063889)%22)&format=json&diagnostics=true&callback=

Solution

  • Yahoo weather APIs are being retired. According to https://developer.yahoo.com/weather ...

    Important EOL Notice

    The weather.yahooapis.com and fallback endpoints are being retired. We will no longer be providing free Weather API services for public users. Please contact [email protected] if you have any questions, comments, or interest in supported paid services.