【问题标题】:Googleapiclient python fit apiGoogleapiclient python fit api
【发布时间】:2018-04-03 13:17:24
【问题描述】:

是否有适用于 google fit 的 googleapiclient 示例或文档 我找不到任何关于 google fit api for python 的文档 我找到的所有示例都是针对谷歌驱动器的 喜欢

import googleapiclient.discovery
drive = googleapiclient.discovery.build(
  API_SERVICE_NAME, API_VERSION, credentials=credentials)

files = drive.files().list().execute()

【问题讨论】:

  • 好吧,你所拥有的东西并不能很好地工作,因为你似乎正在混合谷歌驱动器。
  • 我需要像这个谷歌驱动代码这样的 fit api 文档

标签: python google-api google-api-python-client google-fit google-client


【解决方案1】:

您那里的代码不会很好地工作,因为它似乎与 Google 驱动器有关。

def retrieve_data():
    """
    Run through the OAuth flow and retrieve credentials.
    Returns a dataset (Users.dataSources.datasets):
    https://developers.google.com/fit/rest/v1/reference/users/dataSources/datasets
    """
    flow = OAuth2WebServerFlow(CLIENT_ID, CLIENT_SECRET, OAUTH_SCOPE, REDIRECT_URI)
    authorize_url = flow.step1_get_authorize_url()
    print 'Go to the following link in your browser:'
    print authorize_url
    code = raw_input('Enter verification code: ').strip()
    credentials = flow.step2_exchange(code)

    # Create an httplib2.Http object and authorize it with our credentials
    http = httplib2.Http()
    http = credentials.authorize(http)

    fitness_service = build('fitness', 'v1', http=http)

    return fitness_service.users().dataSources(). \
              datasets(). \
              get(userId='me', dataSourceId=DATA_SOURCE, datasetId=DATA_SET). \
              execute()

检查此文件以获取完整代码 Getfit.py 并确保正确设置重定向 URI

【讨论】:

  • 有效,但我有一个问题,为什么 data_set 参数中的时间以纳秒为单位而不是毫秒
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-08-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多