Upload
chachamaru
View
71
Download
0
Embed Size (px)
Citation preview
ちゃちゃまる
見習いデザインエンジニア
高校生
@chachmaru
LIGブログの読者層を下げる
天気予報スマホアプリはもう遅い!(かも!)
Livedoor - Weather Hacks
"forecasts" : [ { "dateLabel" : "今日", "telop" : "晴のち曇", "date" : "2015-01-15", "temperature" : { "min" : null, "max" : { "celsius" : "11", "fahrenheit" : "51.8" } }, "image" : { "width" : 50, "url" : "http://weather.livedoor.com/img/icon/5.gif", "title" : "晴のち曇", "height" : 31 } }
var http = require('http'); var url = 'http://weather.livedoor.com/forecast/webservice/json/v1?city=130010';
http.get(url, function(res) { var body = ''; res.setEncoding('utf8'); res.on('data', function(data) { body += data; }); res.on('end', function(data) { console.log(JSON.parse(body).forecasts[0].telop); }) });
var url = 'http://weather.livedoor.com/forecast/webservice/json/v1?city=130010';
var weather = '';
http.get(url, function(res) {}
res.setEncoding('utf8');
res.on('data', function(data) {});
var body = ''; res.on('data', function(data) { body += data; });
"forecasts" : [ { "dateLabel" : "今日", "telop" : "晴のち曇", "date" : "2015-01-15", "temperature" : { "min" : null, "max" : { "celsius" : "11", "fahrenheit" : "51.8" } }, "image" : { "width" : 50, "url" : "http://weather.livedoor.com/img/icon/5.gif", "title" : "晴のち曇", "height" : 31 } }
res.on('end', function(data) {}
res.on('end', function(data) { var weather_data = JSON.parse(body); forecasts = weather_data['forecasts']; }
res.on('end', function(data) { var weather_data = JSON.parse(body); forecasts = weather_data['forecasts']; for (index in forecasts) { forecast = forecasts[index]; if (forecast.dateLabel === '今日') { weather = forecast['telop']; console.log(weather); } } })
IoTと連携
お天気スマホアプリはもう要らない。かも。