In order to utilise resources already available on the internet, such as websites it is necessary to have a system in place that is capable of making http request. This enables users of AgNetPro to query information such as weather conditions that is available on external websites/database. This will hopefully operate similarly to frontlinesms trigger function.
The Request module was installed through npm – $ npm install request – and the super sample example in the readme.md file worked out of the box. Changing the url to point to FrontlineSMS http trigger, connection was verified from Nodejs to Frontlinesms, this was not possible in AgNetPro system before as all Nodejs – FrontlineSMS connection was initiated by FrontlineSMS (screenshots to be uploaded which will explain the problem that this solves).
Now for a suitable weather api... 16-04-2012 Google's weather api is an undocumented weather api for all major cities in the world (programmable web google's secret weather api). The api was specifically designed for creating apps (programmable web - google's web api directory ). The secret weather api is available in xml format. (Google search google weather api nodejs - http://www.google.co.uk/search?q=google+weather+api+nodejs&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a) Nodejs google - weather module - accepts city name and date and returns weather forecast https://github.com/maxkueng/node-googleweather Currently AgNetPro queries weather api, weather conditions is returned in xml format, however, must be parsed before conditions can be returned to user (screenshots will be uploaded). Problems currently reported with jsdom (http://stackoverflow.com/questions/10143288/node-js-jsdom-error, https://github.com/tmpvar/jsdom/issues/436) a required library for node googleweather. Error message:
features = JSON.parse(JSON.stringify(window.document.implementation._fea
TypeError: Cannot read property ‘implementation’ of undefined
at Object.env (/**/****/node_modules/jsdom/lib/jsdom.js:262:5)
at Request._callback (/**/****/node_modules/googleweather/lib/googleweather.js:39:10)
at Request.callback (/**/****/node_modules/request/main.js:119:22)
at Request.<anonymous> (native)
at Request.emit (events.js:70:17)
at Request.<anonymous> (/**/****/node_modules/request/main.js:521:16)
at Request.emit (events.js:67:17)
at IncomingMessage.<anonymous> (/**/****/node_modules/request/main.js:483:14)
at IncomingMessage.emit (events.js:88:20)