简体   繁体   English

如何通过Fitness REST API从Google Fitness商店获取每日步数和活动卡路里

[英]How to get daily step count and active calories from google fitness store via Fitness REST API

I am using nodejs and Google's official "googleapis" module. 我正在使用nodejs和Google的官方“ googleapis”模块。 I am unable to get any value field from any data source. 我无法从任何数据源获取任何值字段。

var count = 0;
               async.eachSeries(dataSources, function (source, nextSource) {
                   count++;
                   console.log(count, source.dataStreamId);
                   console.log('------------------------------------------------------------------------------------------------------------------------------');
                   fitness.users.dataSources.datasets.get({
                       dataSourceId: encodeURI(source.dataStreamId),
                       datasetId: new Date('2016-01-01').getTime() + '-' + new Date().getTime(),
                       userId: "me"
                   }, function (err, data) {
                       if (err) {
                           console.log(err);
                           return nextSource(err);
                       }
                       console.log("Data Set");
                       console.log(data);
                       nextSource(null);
                   });
               }, function nextSource(err) {
                   if (err) {
                       return nextTask(err);
                   }
                   nextTask(null, 'OK')
               });

All I get in response is something like: 我得到的回应是:

{ minStartTimeNs: '1451606400000',
  maxEndTimeNs: '1455532058239',
  dataSourceId:   
  'derived:com.google.step_count.delta:com.google.android.gms:estimated_steps' 
}

I had the same problem, but find the sollution. 我遇到了同样的问题,但是找到了解决方法。

"minStartTimeNs: '1451606400000', maxEndTimeNs: '1455532058239'" “ minStartTimeNs:'1451606400000',maxEndTimeNs:'1455532058239'”

They are not in the correct format, the api need epoch time in NANOSECOND (19 number), so its need to 1451606400000000000 and 1455532058239000000 它们的格式不正确,api需要以NANOSECOND(19号)为起始时间,因此它需要1451606400000000000和1455532058239000000

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 OAuth2 和 PassportJS 获取 Google Fitness API 数据 - How to get Google Fitness API data using OAuth2 with PassportJS 如何解决:至少需要一个聚合 - 谷歌健身 api? - How to fix : Require at least one aggregateby - google fitness api? Google Fit REST API:获取每次活动消耗的卡路里 - Google Fit REST API: get calories burned per activity 如何修复错误:需要至少一个聚合? - 健身API - How to fix Error: Require at least one aggregateby? - fitness api 如何通过Node Client从Google API获得真实姓名 - How to get real name from Google API via Node Client Google Fit:API仅获取数据源的详细信息,而不获取nodejs中卡路里的详细信息 - Google Fit: API gets only details of datasources but not the details of calories in nodejs 无法读取未定义的属性(读取“健身”) - Cannot read properties of undefined (reading 'fitness') 我可以通过 Node.js 使用服务帐户从 Google 驱动器下载图像的分步过程吗 - Can I get the step by step process for downloading images from Google drive using the service account via Node.js 通过谷歌http rest api发送电子邮件 - send email via google http rest api Google地理编码-如何使用REST API从经纬度获取参考或ID - Google geocoding - how to get reference or id from lat,lng using REST api
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM