Fitbit "Get Daily Activity Summary" API 调用得到空 "activities" 数组

Fitbit "Get Daily Activity Summary" API call gets empty "activities" array

在我的应用程序中,我进行 API 调用以获取用户的 Fitbit 数据,当我对 "Get Daily Activity Summary" 进行 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
   }
}

我们可以通过两种方式记录活动。

  1. 登录 fitbit 门户 (https://www.fitbit.com/) 并手动登录一个 activity。
  2. 将您的 fitbit 设备与您的应用程序同步(android 或 Iphone)。

在第一种情况下, 当您请求已记录 activity 的那一天时,您将获得活动集合。

假设您在 2016 年 12 月 18 日记录了 activity。

请求Url: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 activity 智能设备,您将无法收集活动数据记录的数据,然后在此处输入代码`rough fitbit band。您可以在 fitbit 门户中查看该数据。这将被记录为 activity 记录。

但是您会看到摘要部分。在哪里可以找到所需的有用信息。像步数、燃烧的卡路里等。所以总是使用摘要部分代替活动收集。

在你的情况下,你没有记录任何 activity 这就是你没有得到的原因 任何活动集合。除了活动收集之外,您获得的数据是我们获得的默认数据,即使那天没有 activity。

试试这个:

它将提供 activity 列表,如 Fitbit 在其网站上显示的那样。

https://api.fitbit.com/1/user/{fitbit-user-id}/activities/list.json?beforeDate=2017-09-29&sort=desc&offset=0&limit=20