问题
I'm trying to get sessions from a startDate to a EndDate, but every time i try return always a empty record
HTTP/1.1 200 OK
Content-length: 3
X-xss-protection: 1; mode=block
Content-location: https://www.googleapis.com/fitness/v1/users/me/sessions?startTime=2015-11-20T00:00:00.00Z&endTime=2015-11-30T23:59:59.99Z
X-content-type-options: nosniff
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Vary: Origin,X-Origin
Server: GSE
Etag: ""
Pragma: no-cache
Cache-control: no-cache, no-store, max-age=0, must-revalidate
Date: Mon, 30 Nov 2015 16:49:52 GMT
X-frame-options: SAMEORIGIN
Content-type: application/json; charset=UTF-8
{}
Heres the URL :https://www.googleapis.com/fitness/v1/users/me/sessions?startTime=2015-11-20T00:00:00.00Z&endTime=2015-11-30T23:59:59.99Z
What is wrong?
I have data in that range and for example if i execute the dataset it return data (https://www.googleapis.com/fitness/v1/users/me/dataSources/derived:com.google.step_count.delta:com.google.android.gms:estimated_steps/datasets/XXXXXXX000000000000-XXXXXX000000000000 )
回答1:
Sessions represent a time interval during which users perform a fitness activity.
It will only appear to the sessions resource items that have been converted to a session.
Normally, automatic tracks (the ones that you don't do anything to track) only become sessions when you put a name on it (you can try it using Google Fit App, selecting one of the auto track activities, put a name of it, like "lunch walk"). It takes a while to become available in the API, in my case, it took one hour to become available to the sessions list.
Another aproach to see itens on the session list is to create a session : create a new activity on Google Fit, with start and stop actions.
You may find more information about the session concept here: https://developers.google.com/fit/android/using-sessions
来源:https://stackoverflow.com/questions/34003804/google-fit-rest-api-get-sessions