1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | function queryFitbitData(username, password, datestr, callbackFn) { var restcall = require('../restcall'); var url = require('url'); //Because the Bluemix service detail includes a URL with the /iot endpoint already //postfixed to the "url", we use the Node.js url module to break it back down so //we can have the host portion for our options JSON object below var iotURLObj = url.parse(iotprops.url); var host = iotURLObj.host; var authStr = username+":"+password; var endpoint = "/iot/doc?id=fb_activity_"+datestr+"&appId="+iotprops.appId; var options = { host: host, path: endpoint, method: "GET", auth: authStr }; console.log("URL: "+host+" / Endpoint: "+endpoint); //send the request to the IoT API restcall.get(options, true, callbackFn); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | "summary": { "distances": [ { "distance": 5.56, "activity": "total" }, { "distance": 5.56, "activity": "tracker" }, { "distance": 23.01, "activity": "loggedActivities" }, { "distance": 2.44, "activity": "veryActive" }, { "distance": 2.17, "activity": "moderatelyActive" }, { "distance": 0.94, "activity": "lightlyActive" }, { "distance": 0, "activity": "sedentaryActive" }, { "distance": 23.01, "activity": "Cycling" } ], "sedentaryMinutes": 733, "lightlyActiveMinutes": 113, "caloriesOut": 3120, "caloriesBMR": 1836, "marginalCalories": 1107, "fairlyActiveMinutes": 77, "veryActiveMinutes": 49, "activityCalories": 1489, "steps": 8404, "activeScore": -1 }, "iot_source": "fitbit", "goals": { "activeMinutes": 30, "distance": 8.05, "caloriesOut": 2925, "steps": 10000 } |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |