old-silvrgit/lib/swedishword.js
2016-02-20 00:44:28 +00:00

45 lines
1003 B
JavaScript

/**
* Created by Martin on 15/02/2016.
*/
var http = require('http'), request = require('request'), util = require('util');
var jsonfile = require('jsonfile');
var log4js = require('log4js');
var logger = log4js.getLogger();
var to_json = require('xmljson').to_json;
require('sugar-date');
var file = __dirname + '/' + 'cal.json';
function saveData(v) {
jsonfile.writeFileSync(file, v);
}
module.exports = {
getSwedishWord: function (cb) {
var t= new Date(), ms = t.getTime();
url = ['http://wotd.transparent.com/rss/swedish-widget.xml?t=', ms].join('');
logger.info(url);
request(url, function (err, resp, body) {
if (err)
throw err;
logger.debug(body);
to_json(body, function (error, data) {
console.log(data);
if(typeof cb === 'function') {
cb(data);
}
});
});
}
};
//module.exports.getSwedishWord();