Reputation: 535
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=
Upvotes: 0
Views: 671
Reputation: 196
I think you are missing "near the WHERE text=
Replace
$yql_query = 'select * from weather.forecast where woeid in (SELECT woeid FROM geo.places WHERE text=('.$time->latitude.','.$time->longitude.'))';
with
$yql_query = 'select * from weather.forecast where woeid in (SELECT woeid FROM geo.places WHERE text="(' . $time->latitude . ',' . $time->longitude . ')")';
if you get Curl error: SSL certificate problem: unable to get local issuer certificate. then use
curl_setopt($session, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($session, CURLOPT_SSL_VERIFYPEER, 0);
Upvotes: 0
Reputation: 26
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.
Upvotes: 1