通过Google python api库使用Google fit数据
我用的是谷歌的,但我不知道用什么来表达“身体”的论点。是否有一个示例体,我可以从中提取来创建此工具所需的dict 以下是我正在使用的代码:通过Google python api库使用Google fit数据,python,google-fit,Python,Google Fit,我用的是谷歌的,但我不知道用什么来表达“身体”的论点。是否有一个示例体,我可以从中提取来创建此工具所需的dict 以下是我正在使用的代码: flow = client.flow_from_clientsecrets( workLaptop, scope='https://www.googleapis.com/auth/fitness.activity.read', redirect_uri='oauth:code:from:somehwere') auth_uri =
flow = client.flow_from_clientsecrets(
workLaptop,
scope='https://www.googleapis.com/auth/fitness.activity.read',
redirect_uri='oauth:code:from:somehwere')
auth_uri = flow.step1_get_authorize_url()
webbrowser.open_new(auth_uri)
auth_code = "a;ldskjfa;lsdkfja;ldsfkja;lsdkfjaldgha;"
credentials = flow.step2_exchange(auth_code)
http_auth = credentials.authorize(httplib2.Http())
service = discovery.build('fitness', 'v1',http_auth)
fitData = service.users().dataset().aggregate(userId='me',body=body).execute()
在我需要定义身体的部分之前,一切都很好。这是我正在尝试的身体:
body = {
"aggregateBy": [
{
"dataSourceId": "derived:com.google.step_count.delta:com.google.android.gms:estimated_steps",
"dataTypeName": "com.google.step_count.delta"
},
],
"bucketByActivitySegment": {
"minDurationMillis": "A String", # Only activity segments of duration longer than this is used
},
"endTimeMillis": "1435269600000000000",
"bucketBySession": {
"minDurationMillis": "10", # Only sessions of duration longer than this is used
},
"bucketByActivityType": {
"minDurationMillis": "10", # Only activity segments of duration longer than this is used
},
"startTimeMillis": "1435183200000000000", # required time range
"bucketByTime": { # apparently oneof is not supported by reduced_nano_proto
"durationMillis": "10",
},
}
我的身体有什么问题?以下是错误代码:
https://www.googleapis.com/fitness/v1/users/me/dataset:aggregate?alt=json 返回“内部错误”>
以下是API资源管理器中对象的示例:
尽管我对Google Fit的Google API不是百分之百满意,但在第一个实例中,您的JSON正文请求肯定存在一些问题 例如:
body = {
"aggregateBy": [
{
"dataSourceId": "derived:com.google.step_count.delta:com.google.android.gms:estimated_steps",
"dataTypeName": "com.google.step_count.delta"
},
],
"bucketByActivitySegment": {
"minDurationMillis": "A String", # Only activity segments of duration longer than this is used
},
"endTimeMillis": "1435269600000000000",
"bucketBySession": {
"minDurationMillis": "10", # Only sessions of duration longer than this is used
},
"bucketByActivityType": {
"minDurationMillis": "10", # Only activity segments of duration longer than this is used
},
"startTimeMillis": "1435183200000000000", # required time range
"bucketByTime": { # apparently oneof is not supported by reduced_nano_proto
"durationMillis": "10",
},
}
其实应该是这样,
body = {
"aggregateBy": [
{
"dataSourceId": "derived:com.google.step_count.delta:com.google.android.gms:estimated_steps",
"dataTypeName": "com.google.step_count.delta"
}
],
"bucketByActivitySegment": {
"minDurationMillis": "A String" # Only activity segments of duration longer than this is used
},
"endTimeMillis": "1435269600000000000",
"bucketBySession": {
"minDurationMillis": "10" # Only sessions of duration longer than this is used
},
"bucketByActivityType": {
"minDurationMillis": "10" # Only activity segments of duration longer than this is used
},
"startTimeMillis": "1435183200000000000", # required time range
"bucketByTime": { # apparently oneof is not supported by reduced_nano_proto
"durationMillis": "10"
}
}
基于JSON的rest服务确实不允许在不应该使用的地方使用额外的逗号,它会导致字符串不可压缩,这将导致失败。首先尝试一下;) 尽管我对Google Fit的Google API不是百分之百满意,但在第一个实例中,您的JSON body请求肯定存在一些问题 例如:
body = {
"aggregateBy": [
{
"dataSourceId": "derived:com.google.step_count.delta:com.google.android.gms:estimated_steps",
"dataTypeName": "com.google.step_count.delta"
},
],
"bucketByActivitySegment": {
"minDurationMillis": "A String", # Only activity segments of duration longer than this is used
},
"endTimeMillis": "1435269600000000000",
"bucketBySession": {
"minDurationMillis": "10", # Only sessions of duration longer than this is used
},
"bucketByActivityType": {
"minDurationMillis": "10", # Only activity segments of duration longer than this is used
},
"startTimeMillis": "1435183200000000000", # required time range
"bucketByTime": { # apparently oneof is not supported by reduced_nano_proto
"durationMillis": "10",
},
}
其实应该是这样,
body = {
"aggregateBy": [
{
"dataSourceId": "derived:com.google.step_count.delta:com.google.android.gms:estimated_steps",
"dataTypeName": "com.google.step_count.delta"
}
],
"bucketByActivitySegment": {
"minDurationMillis": "A String" # Only activity segments of duration longer than this is used
},
"endTimeMillis": "1435269600000000000",
"bucketBySession": {
"minDurationMillis": "10" # Only sessions of duration longer than this is used
},
"bucketByActivityType": {
"minDurationMillis": "10" # Only activity segments of duration longer than this is used
},
"startTimeMillis": "1435183200000000000", # required time range
"bucketByTime": { # apparently oneof is not supported by reduced_nano_proto
"durationMillis": "10"
}
}
基于JSON的rest服务确实不允许在不应该使用的地方使用额外的逗号,它会导致字符串不可压缩,这将导致失败。首先尝试一下;) 我自己不是专家,但我已经玩了好几天API了。这是我的OAuth游乐场的一个样本
据我所知,你的“endTimeMillis”:“1435269600000000000”没有正确定义为纳秒。如果要使用milli,请将其更改为“1435269600000”我自己不是专家,但我已经使用API好几天了。这是我的OAuth游乐场的一个样本
据我所知,你的“endTimeMillis”:“1435269600000000000”没有正确定义为纳秒。要使其以毫为单位,请将其更改为“1435269600000”这里是API explorer链接:它允许您使用该工具“制作”一个主体dict,但我找不到一个将返回值的组合。这里是API explorer链接:它允许您使用该工具“制作”一个主体dict,但我找不到一个将返回值的组合。看起来不是那么简单。仍然有500个错误(.我真正需要的是一个有效的示例配置。我很惊讶谷歌没有在什么地方给出这个配置。
“minDurationMillis”:“字符串”
看起来无效似乎没有那么简单。仍然有500个错误。:(.我真正需要的是一个有效的示例配置。我很惊讶谷歌没有在什么地方给出这个配置。“minDurationMillis”:“字符串”
看起来无效