在我的应用程序中,我进行API调用以获取用户的Fitbit数据,当我对“获取每日活动摘要”进行API调用时,我得到了空的活动数组。
我从这个API调用中获取了所有信息,但活动数组却显示为空[]。以下是API调用的示例响应。
{
"activities":[
],
"goals":{
"caloriesOut":2826,
"distance":8.05,
"floors":150,
"steps":10000
},
"summary":{
"activityCalories":230,
"caloriesBMR":1913,
"caloriesOut":2143,
"distances":[
{
"activity":"tracker",
"distance":1.32
},
{
"activity":"loggedActivities",
"distance":0
},
{
"activity":"total",
"distance":1.32
},
{
"activity":"veryActive",
"distance":0.51
},
{
"activity":"moderatelyActive",
"distance":0.51
},
{
"activity":"lightlyActive",
"distance":0.51
},
{
"activity":"sedentaryActive",
"distance":0.51
},
{
"activity":"Treadmill, 0% Incline",
"distance":3.28
}
],
"elevation":48.77,
"fairlyActiveMinutes":0,
"floors":16,
"lightlyActiveMinutes":0,
"marginalCalories":200,
"sedentaryMinutes":1166,
"steps":0,
"veryActiveMinutes":0
}
}
最佳答案
我们可以通过两种方式记录活动。
登录到fitbit门户(https://www.fitbit.com/)并手动记录一项活动。
将Fitbit设备与您的应用程序(Android或Iphone)同步。
在第一种情况下,
当您请求记录活动的当天时,您将获得活动集合。
假设您记录了2016年12月18日的活动。
请求网址:https://api.fitbit.com/1/user/-/activities/date/2016-12-18.json
响应:
{
"activities": [
{
"activityId": 12030,
"activityParentId": 90009,
"activityParentName": "Run",
"calories": 530,
"description": "Running - 5 mph (12 min/mile)",
"distance": 1,
"duration": 3600000,
"hasStartTime": true,
"isFavorite": false,
"lastModified": "2016-12-19T12:07:51.124Z",
"logId": 5218814487,
"name": "Run",
"startDate": "2016-12-18",
"startTime": "06:00",
"steps": 843
}
],
"goals": {
"activeMinutes": 30,
"caloriesOut": 2689,
"distance": 8.05,
"steps": 10000
},
"summary": {
"activeScore": -1,
"activityCalories": 1658,
"caloriesBMR": 1588,
"caloriesOut": 2927,
"distances": [
{
"activity": "Run",
"distance": 1
},
{
"activity": "total",
"distance": 7.42
},
{
"activity": "tracker",
"distance": 7.1
},
{
"activity": "loggedActivities",
"distance": 1
},
{
"activity": "veryActive",
"distance": 1.99
},
{
"activity": "moderatelyActive",
"distance": 0.03
},
{
"activity": "lightlyActive",
"distance": 5.41
},
{
"activity": "sedentaryActive",
"distance": 0
}
],
"fairlyActiveMinutes": 1,
"lightlyActiveMinutes": 297,
"marginalCalories": 961,
"sedentaryMinutes": 108,
"steps": 9982,
"veryActiveMinutes": 74
}
}
在第二种情况下,如果您有fitbit活动跟踪器,则不会在此处记录粗略的fitbit频段的活动代码收集活动。您可以在fitbit门户中检查该数据。这将记录为活动记录。
但是您将获得摘要部分。在这里您将找到所需的有用信息。像步骤,消耗的卡路里等。因此,请始终使用摘要部分代替活动收集。
就您而言,您尚未记录任何活动,因此您没有得到
任何活动集合。除了活动收集之外,即使当天没有活动,您得到的数据也是我们获得的默认数据。
关于c# - Fitbit“获取每日事件摘要” API调用获取空的“事件”数组,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/41220431/