0

YQL weather http://query.yahooapis.com/v1/public/yql?format=json&rnd='

So im getting an error saying result are null when i use the query http://query.yahooapis.com/v1/public/yql? to get weather. Anyone else having trouble getting the weather recently? has yahoo API changed recently?

Also Im doing this form SharePoint 2010

/* * simpleWeather * http://simpleweatherjs.com * * A simple jQuery plugin to display the current weather * information for any location using Yahoo! Weather. * * Developed by James Fleeting <@twofivethreetwo> http://iwasasuperhero.com * Another project from monkeeCreate http://monkeecreate.com * * Version 2.3.0 - Last updated: June 16 2013 */ (function($) { "use strict"; $.extend({ simpleWeather: function(options){ options = $.extend({ zipcode: '', woeid: '2357536', location: '', unit: 'f', success: function(weather){}, error: function(message){} }, options);

        var now = new Date();

        var weatherUrl = '<http://query.yahooapis.com/v1/public/yql?format=json&rnd=>'+now.getFullYear()+now.getMonth()+now.getDay()+now.getHours()+'&diagnostics=true&callback=?&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&q=';
        if(options.location !== '') {
            weatherUrl += 'select * from weather.forecast where location in (select id from weather.search where query="'+options.location+'") and u="'+options.unit+'"';
        } else if(options.zipcode !== '') {
            weatherUrl += 'select * from weather.forecast where location in ("'+options.zipcode+'") and u="'+options.unit+'"';
        } else if(options.woeid !== '') {
            weatherUrl += 'select * from weather.forecast where woeid='+options.woeid+' and u="'+options.unit+'"';
        } else {
            options.error("Could not retrieve weather due to an invalid WOEID or location.");
            return false;
        }

        $.getJSON(
            weatherUrl,
            function(data) {
                if(data !== null && data.query.results !== null && data.query.results.channel.description !== 'Yahoo! Weather Error') {
                    $.each(data.query.results, function(i, result) {
                        if (result.constructor.toString().indexOf("Array") !== -1) {
                            result = result[0];
                        }

                        var currentDate = new Date();
                        var sunRise = new Date(currentDate.toDateString() +' '+ result.astronomy.sunrise);
                        var sunSet = new Date(currentDate.toDateString() +' '+ result.astronomy.sunset);

by
1 Reply
  • Seems some of your parameter was wrong. Can you execute every YQL separately on some and see if that works, if not let me know !

    1

Recent Posts

in YQL