Skip to content

Instantly share code, notes, and snippets.

@oshliaer
Created May 27, 2015 07:19
Show Gist options
  • Save oshliaer/46b1f4920a80dbbca80d to your computer and use it in GitHub Desktop.
Save oshliaer/46b1f4920a80dbbca80d to your computer and use it in GitHub Desktop.
Lists sessions previously created #gapi #fit
function getFitActivity(pageToken) {
var params = {};
if(pageToken) params.pageToken = pageToken;
params.startTime = '2014-12-18T00:00:00.00Z';
params.endTime = '2014-12-18T17:34:00.00Z';
var request = gapi.client.request({
'path' : '/fitness/v1/users/me/sessions',
'method' : 'GET',
'params' : params
}).then(opt_onFulfilled, opt_onRejected);
}
function opt_onRejected(e) {
console.log(e);
}
function opt_onFulfilled(e) {
console.log(e);
if(e.result.session)
for(var i = 0; i < e.result.session.length; i++){
console.log(e.result.session[i].startTimeMillis);
console.log('st', new Date(parseFloat(e.result.session[i].startTimeMillis)), 'et', new Date(parseFloat(e.result.session[i].endTimeMillis)));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment