Google 健身无法从 API 中获取卡路里

GoogleFit can't get back calories from API

我在使用 GoogleFit API 时遇到问题,我可以在其中恢复步数但无法获取卡路里。

这是 URL 我正在制作一个 POST 到 :

https://fitness.googleapis.com/fitness/v1/users/me/dataset:aggregate

这是 JSON 中的正文:

{
  "aggregateBy": [{
    "dataSourceId": "derived:com.google.calories.expended:com.google.android.gms:from_activities" 
  }],
  "bucketByTime": { "durationMillis":86400000 },
  "startTimeMillis" : 1617235200000,
  "endTimeMillis" : 1617287510000
}

这是回复:

{
    "bucket": [
        {
            "startTimeMillis": "1617235200000",
            "endTimeMillis": "1617287510000",
            "dataset": [
                {
                    "dataSourceId": "derived:com.google.calories.expended:com.google.android.gms:aggregated",
                    "point": []
                }
            ]
        }
    ]
}

我建议按数据 type 而非数据 source:

进行汇总
  "aggregateBy": [{
    "dataTypeName": "com.google.calories.expended" 
  }],

derived:com.google.calories.expended:com.google.android.gms:from_activities这样的流是一些实现细节。