rest - 我们如何使用 Google Fit rest API 获取当天的实时步数?
问题描述
在使用 Google Fit Rest API 进行健身活动时,它为我提供了前几天的数据以及适当的步数,但无法提供当天的计数。即使在我的手机中,Google Fit 同步过程也正常运行,并且我的互联网运行良好。
如果我强制同步(手动),那么它可以开始提供当天的步数和其他活动数据。否则,只能显示 9 点(或每日第一个同步周期)之前的数据。之后,它只能在 API 响应中以相同的时间范围更新第二天的步数。
下面我分享了带有所需参数的 API 详细信息:
HTTP方法:POST
请求网址:https ://www.googleapis.com/fitness/v1/users/me/dataset:aggregate
请求正文:
{
"aggregateBy": [{
"dataTypeName": "com.google.step_count.delta",
"dataSourceId": "derived:com.google.step_count.delta:com.google.android.gms:estimated_steps"
}],
"bucketByTime": { "durationMillis": 86400000 },
"startTimeMillis": 1559154600000,
"endTimeMillis": 1559241000000
}
回复 :
{
"bucket": [
{
"startTimeMillis": "1559154600000",
"endTimeMillis": "1559241000000",
"dataset": [
{
"dataSourceId": "derived:com.google.step_count.delta:com.google.android.gms:aggregated",
"point": [
{
"startTimeNanos": "1559181787309598125",
"endTimeNanos": "1559183772877349957",
"dataTypeName": "com.google.step_count.delta",
"originDataSourceId": "raw:com.google.step_count.cumulative:Realme:RMX1833:355d9abc461f5254:STEP_COUNTER",
"value": [
{
"intVal": 233,
"mapVal": []
}
]
}
]
}
]
}
]
}
目前,它只能显示从早上算起的 233 步,而 Google Fit 应用程序显示了 4674 步。如何获得与 Google Fit App 可以显示的相同的数字?
解决方案
推荐阅读
- python-3.x - Scrapy:从页面内容派生的字段名称
- javascript - 根据 id 和 date 删除数组中的重复对象
- jquery - Django ajax 帖子在 Web 主机上引发 500 错误,但在 localhost 上有效
- java - 我的通知代码突然停止工作
- windows - Windows 回收站信息文件二进制格式
- python - 如何在没有堆栈跟踪的情况下创建 Python 异常?
- dart - Riverpod StreamProvider 访问流
- python - Django admin Page 404 Not Found & 错误处理页面不工作(DEBUG_PROPAGATE_EXCEPTIONS)
- xamarin - 无法从 Visual Studio For Mac 在 iPhone 模拟器中运行 Xamarin 应用程序
- ios - 快速绘制带有笔画动画的复选标记