3 Replies Latest reply on Dec 28, 2016 10:36 AM by ttielebein RSS
    msutton Newbie

    Open weather app tutorial problem

    Hi Everyone


    I am having a problem with the open weather app tutorial. I have followed the tutorial but i get an error when testing the code. I have created my own API key using the link in the tutorial. I didn't know if there may be an issue with having copied the code from the PDF and whether formatting has been lost.


    See error below


    Wrapped org.apache.http.conn.HttpHostConnectException: Connect to api.openweathermap.org:80 [api.openweathermap.org/, api.openweathermap.org/] failed: Connection timed out: connect Cause: Connect to api.openweathermap.org:80 [api.openweathermap.org/, api.openweathermap.org/] failed: Connection timed out: connect


    And the code i'm using below


    var stringLocation=location+" ";

    var arrayLocations=stringLocation.split(",");

    var lat=arrayLocations[0];

    var long=arrayLocations[1];

    //Modify the open weather url here if you are using your own API key

    var params = {

      url: "http://api.openweathermap.org/data/2.5/forecast?lat="+lat+"&lon="+long+"&units=imperial" +"&type=accurate&mode=xml&APPID=75239107b41bd2c2a72e2e3c7b89b550" /* STRING*/,

      timeout: 160 /* NUMBER */


    // result: XML

    var xmlPage = Resources["ContentLoaderFunctions"].LoadXML(params);

    var params = {

      infoTableName : "InfoTable",

      dataShapeName : "OpenWeatherFeed"




    // CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"),dataShapeName:STRING:INFOTABLE(OpenWeatherFeed)

    var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);

      var from_today_value=xmlPage.forecast.time[0].@from.substring(0,10);

      a.logger.warn("from_today_value= "+from_today_value);

    for each (var item in xmlPage.forecast.time) {

      var row = new Object();

      var from_current_value=item.@from.substring(0,10);



      row.WindDirection = item.windDirection.@name;






      row.Title=xmlPage.location.name+" "+xmlPage.location.country;

      row.Precipitation=(item.precipitation.@type+" "+item.precipitation.@value)==" "?"NoPrecipitation":item.precipitation.@type;




    Thanks Matt