Google FIT Rest API获取自动跟踪

时间:2018-11-09 21:17:45

标签: rest api google-fit

我尝试通过Google Fit REST API获取Google Fit在我的android手机上存储的自动跟踪。 (例如:自行车会话,开始日期,持续时间,活动类型的自行车,步行...)

我只是尝试了session API

GET /fitness/v1/users/me/sessions?startTime=2018-11-09T00:00:00.00Z&endTime=2018-11-09T23:59:59.99Z HTTP/1.1

但是我没有结果:

HTTP/1.1 200 OK
Content-length: 42
X-xss-protection: 1; mode=block
Content-location: https://www.googleapis.com/fitness/v1/users/me/sessions?startTime=2018-11-09T00:00:00.00Z&endTime=2018-11-09T23:59:59.99Z
X-content-type-options: nosniff
Transfer-encoding: chunked
Expires: Fri, 09 Nov 2018 20:50:48 GMT
Vary: Origin, X-Origin
Server: GSE
Etag: "977qOFam2oE2uMtwc7J4i3egnsw/vyGp6PvFo4RvsFtPoIWeCReyIC8"
Cache-control: private, max-age=0, must-revalidate, no-transform
Date: Fri, 09 Nov 2018 20:50:48 GMT
X-frame-options: SAMEORIGIN
Alt-svc: quic=":443"; ma=2592000; v="44,43,39,35"
Content-type: application/json; charset=UTF-8
-content-encoding: gzip
{
  "deletedSession": [], 
  "session": []
}

我也尝试执行aggregate

POST /fitness/v1/users/me/dataset:aggregate HTTP/1.1
Host: www.googleapis.com
Content-length: 281
Content-type: application/json
Authorization: Bearer XXXXXX
{
  "aggregateBy": [
    {
            "dataSourceId": "derived:com.google.activity.segment:com.google.android.gms:merge_activity_segments"

    }
  ],
  "bucketByActivityType": { "durationMillis": 86400000 }, 
  "startTimeMillis": 1541621627000,
  "endTimeMillis": 1541797627000
}

我得到了结果,但是我找不到任何解密方法!

{
  "bucket": [
    {
      "activity": 1, 
      "dataset": [
        {
          "dataSourceId": "derived:com.google.activity.summary:com.google.android.gms:aggregated", 
          "point": [
            {
              "startTimeNanos": "1541662372620000000", 
              "originDataSourceId": "derived:com.google.activity.segment:com.google.android.gms:merge_activity_segments", 
              "endTimeNanos": "1541778156173000000", 
              "value": [
                {
                  "mapVal": [], 
                  "intVal": 1
                }, 
                {
                  "mapVal": [], 
                  "intVal": 6216497
                }, 
                {
                  "mapVal": [], 
                  "intVal": 6
                }
              ], 
              "dataTypeName": "com.google.activity.summary"
            }
          ]
        }
      ]
    }, 
    {
      "activity": 3, 
      "dataset": [
        {
          "dataSourceId": "derived:com.google.activity.summary:com.google.android.gms:aggregated", 
          "point": [
            {
              "startTimeNanos": "1541621627000000000", 
              "originDataSourceId": "derived:com.google.activity.segment:com.google.android.gms:merge_activity_segments", 
              "endTimeNanos": "1541796648562000000", 
              "value": [
                {
                  "mapVal": [], 
                  "intVal": 3
                }, 
                {
                  "mapVal": [], 
                  "intVal": 163981252
                }, 
                {
                  "mapVal": [], 
                  "intVal": 11
                }
              ], 
              "dataTypeName": "com.google.activity.summary"
            }
          ]
        }
      ]
    }, 
    {
      "activity": 7, 
      "dataset": [
        {
          "dataSourceId": "derived:com.google.activity.summary:com.google.android.gms:aggregated", 
          "point": [
            {
              "startTimeNanos": "1541667650063000000", 
              "originDataSourceId": "derived:com.google.activity.segment:com.google.android.gms:merge_activity_segments", 
              "endTimeNanos": "1541779218129000000", 
              "value": [
                {
                  "mapVal": [], 
                  "intVal": 7
                }, 
                {
                  "mapVal": [], 
                  "intVal": 3443813
                }, 
                {
                  "mapVal": [], 
                  "intVal": 13
                }
              ], 
              "dataTypeName": "com.google.activity.summary"
            }
          ]
        }
      ]
    }, 
    {
      "activity": 58, 
      "dataset": [
        {
          "dataSourceId": "derived:com.google.activity.summary:com.google.android.gms:aggregated", 
          "point": [
            {
              "startTimeNanos": "1541792220000000000", 
              "originDataSourceId": "derived:com.google.activity.segment:com.google.android.gms:merge_activity_segments", 
              "endTimeNanos": "1541793600000000000", 
              "value": [
                {
                  "mapVal": [], 
                  "intVal": 58
                }, 
                {
                  "mapVal": [], 
                  "intVal": 1380000
                }, 
                {
                  "mapVal": [], 
                  "intVal": 1
                }
              ], 
              "dataTypeName": "com.google.activity.summary"
            }
          ]
        }
      ]
    }
  ]
}

我正在寻找任何建议,在Google开发人员门户上看不到任何用例真的很奇怪。在这个阶段,我没有提到不可能或无法实现此用例的任何提示。

0 个答案:

没有答案