Google Fit:API仅获取数据源的详细信息,但不获取nodejs中卡路里的详细信息

时间:2016-02-19 11:22:09

标签: node.js google-api google-fit google-api-nodejs-client

我只是获取了dataSources的详细信息,但我没有从google fit中获得卡路里。如何才能获得燃烧卡路里的细节。 我可以从(Google Fitness API returns only {} as result)此代码中获取此信息,如下所示,但不是活动信息。

Request:
https://www.googleapis.com/fitness/v1/users/me/dataSources/derived:com.google.calories.expended:com.google.calories.consumed:merge_calories_expended?access_token=88888888888888888888

Response:
{ dataStreamId: 'derived:com.google.calories.expended:com.google.calories.consumed:merge_calories_expended',
       dataStreamName: 'merge_calories_expended',
       type: 'derived',
       dataType: [Object],
       application: [Object] }

1 个答案:

答案 0 :(得分:0)

您可以通过发送GET请求列出可用的数据源 https://www.googleapis.com/fitness/v1/users/me/dataSources

查看结果我可以看到dataSource id“derived:com.google.calories.expended:com.google.android.gms:platform_calories_expended”

在URL中使用它,我得到卡路里数据集: https://www.googleapis.com/fitness/v1/users/me/dataSources/derived:com.google.calories.expended:com.google.android.gms:platform_calories_expended/datasets/1451606400000000000-1455888676947965751

由于:

   {
    "minStartTimeNs"=>"1451606400000000000",
    "maxEndTimeNs"=>"1455888676947965751",
    "dataSourceId"=>
 "derived:com.google.calories.expended:com.google.android.gms:platform_calories_expended",
 "point"=>
  [{"startTimeNanos"=>"1455883200000000000",
    "endTimeNanos"=>"1455883500000000000",
    "dataTypeName"=>"com.google.calories.expended",
    "originDataSourceId"=>
"derived:com.google.calories.expended:com.google.android.gms:from_activities",
    "value"=>[{"fpVal"=>5.666666507720947}],
    "modifiedTimeMillis"=>"1455888999993"}]}

另见https://support.google.com/fit/?hl=en#6075066

上的说明
  

注意:要查看您已经消失的距离或燃烧的卡路里数,您需要填写身高,体重和性别。