XWidgetSoft Forum
https://www.bbs.xwidget.com/

Pollen Tag in AccWeatherCore?
https://www.bbs.xwidget.com/viewtopic.php?f=3&t=4023
Page 1 of 1

Author:  MSkiles31 [ January 24th, 2014, 12:05 pm ]
Post subject:  Pollen Tag in AccWeatherCore?

Would it be possible to add a pollen tag for extracting the pollen data from this "core"?

I noticed that the the "AccuWeatherCore2*" cached file appears to already have the pollen data; however, I'm unable to locate a "pollen" tag in the XWidget Designer tool (under Add tag).

JSON Snippet with Pollen data:
Code:
"AirAndPollen":[{"Name":"AirQuality","Value":25,"Category":"Good","CategoryValue":1,"Type":"Ozone"},{"Name":"Grass","Value":0,"Category":"Low","CategoryValue":1},{"Name":"Mold","Value":400,"Category":"Low","CategoryValue":1},{"Name":"Ragweed","Value":0,"Category":"Low","CategoryValue":1},{"Name":"Tree","Value":50,"Category":"Moderate","CategoryValue":2}


File Location: C:\Users\..\Documents\xwidget\Cache

Thanks,
Matt

Author:  digigamer [ January 25th, 2014, 7:42 pm ]
Post subject:  Re: Pollen Tag in AccWeatherCore?

There is lots of candid stuff that Accuweather sends but unfortunately not all are exposed through the tags. One solution is to load the json and get the objects manually.

Author:  MSkiles31 [ January 25th, 2014, 9:55 pm ]
Post subject:  Re: Pollen Tag in AccWeatherCore?

digigamer wrote:
There is lots of candid stuff that Accuweather sends but unfortunately not all are exposed through the tags. One solution is to load the json and get the objects manually.


Thanks!

Is there a way to pull back the raw JSON via the native JavaScript API in XWidget instead of retrieving it from the local cached file?


Code:
  ...
    //file_get_contents_async('http://api.vkontakte.ru/method/users.get?uids=1&fields=photo_200',
    file_get_contents_async('C:\\Users\\user123\\Desktop\\test.json',
        function(response)
    {
       //get the json.. lets say that is stored in a obj
       //response is the downloaded string...
        var obj = JSON.parse(response);
        //var uid = obj.response[0].uid;
        //var firstName = obj.response[0].first_name;
        //var lastName = obj.response[0].last_name;
        //var avatar = obj.response[0].photo_200;
        //alert(lastName);
        var name = obj.DailyForecasts[0].AirAndPollen[2].Name;
        var value = obj.DailyForecasts[0].AirAndPollen[2].Value;
        var category = obj.DailyForecasts[0].AirAndPollen[2].Category;
        var categoryVal = obj.DailyForecasts[0].AirAndPollen[2].CategoryValue;

        alert(categoryVal);
    });


Code:
function file_get_contents_async( url ,callback) {
var req = null;
 try { req = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {
 try { req = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {
 try { req = new XMLHttpRequest(); } catch(e) {}
 }
 }
 if (req == null) throw new Error('XMLHttpRequest not supported');

req.open("GET",url,true);
req.onreadystatechange=function() {
 if (req.readyState==4) {
 var response = req.responseText;
 callback(response);
 }};
req.send(null);
}


Attachments:
File comment: Cached Accuweather JSON Files
Screenshot - 1_25_2014 , 9_50_53 PM.jpg
Screenshot - 1_25_2014 , 9_50_53 PM.jpg [ 18.97 KiB | Viewed 4127 times ]

Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/